您当前的位置: 首页 > 

minato_yukina

暂无认证

  • 2浏览

    0关注

    138博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Codeforeces #711 DIV2 (A-C) 题解(部分 A-C)

minato_yukina 发布时间:2021-03-30 23:07:22 ,浏览量:2

Div2就是刺激啊,人菜瘾大中 目前仅有A-C(人菜).

A.GCD Sum

.题意:给一个数n,定义一个数的gcdsum是 n与其各个位置上数字之和的GCD。比如说gcdsum(762)=gcd(762,7+6+2)=3.现在给你一个数n,找一个大于等于它的数x,令gcdsum(x)>1 。 分析: 模拟即可。记住在分离各个数和的时候要用一个变量保存当前的x.不然就会出现gcd(0,sum)的情况 代码:

#include
using namespace std;
long long gcd(long long a,long long b){
	if(b==0) return a;
	return gcd(b,a%b);
}
long long gcdsum(long long x){
	long long sum=0;long long n=x;
	while(x) {
		sum+=x%10;
		x/=10;
		}
	return gcd(n,sum);	
}
int main(){
	int T;cin>>T;
	while(T--){
		long long n;
		cin>>n;
		while(true){
			if(gcdsum(n)>1) {
				coutn>>w;
		multiset s;
		for(int i=0;i>k;
		if(k==1) {
			cout            
关注
打赏
1663570241
查看更多评论
0.0403s