其他分享
首页 > 其他分享> > 简单加法(基本型)

简单加法(基本型)

作者:互联网

code

#include<algorithm>
#include<iostream>
using namespace std;
bool check(int i){
	int a=i,b=i+1,c=i+2;
	while(a||b||c){
		//TODO test carry bit
		if((a%10+b%10+c%10)/10){
			//TODO have carry bit
			return false;
		}
		a/=10,b/=10,c/=10;//try next bit
	}
	return true;
}
int main(){
	ios::sync_with_stdio(false);
	int n,cnt=0;
	cin>>n;
	for(int i=0;i<n;i++){
		if(check(i)){
			cnt++;
		}
	}
	cout<<cnt<<'\n';
	return 0;
}

ref

ref

标签:10,false,int,加法,基本型,简单,carry,return,bit
来源: https://www.cnblogs.com/jeseesmith/p/15862687.html