[Zhengqing] [1759] Double eleven

Problem Description

Loading...

Problem Analysis

It was a bit cumbersome to write back then
but at least it didn’t TLE…
Let’s just leave it as it is~

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include<stdio.h>
int main() {
	int i,t,n,m,x;
	scanf("%d %d",&n,&m);
	for(i=n,x=0; i<=m; i++) {
		t=i;
		while(t/10!=0) {
			if(t%10==1)
				x++;
			t/=10;
		}
		if(t==1)
			x++;
	}
	printf("%d",x);
	return 0;
}

Problem link: [ZZULI] [1759] Double eleven

This post is licensed under CC BY-NC-SA 4.0. If it helped, or if you have anything to say, the comment box below is open.
Page views —
Unique visitors —

Loading...