Example #1
0
int main(){
    int n;
    while(1){
        scanf("%d", &n);
        printf("%d\n",sod(n));
    }
    return 0;
}
Example #2
0
File: 11743.cpp Project: dibery/UVa
int main()
{
	int t, mono[ 8 ], bi[ 8 ];
	char n[ 21 ];

	for( scanf( "%d", &t ); t--; )
	{
		int m = 0, b = 0;

		scanf( "%s %s %s %s", n, n+4, n+8, n+12 );
		for( int i = 0; i < 16; ++i )
			if( i % 2 == 0 )
				bi[ i >> 1 ] = n[ i ] - '0' << 1;
			else
				mono[ i >> 1 ] = n[ i ] - '0';
		for( int i = 0; i < 8; ++i )
			m += sod( mono[ i ] ), b += sod( bi[ i ] );
		puts( ( m + b ) % 10? "Invalid" : "Valid" );
	}
Example #3
0
int main(void){
	for(int i, j, n; scanf("%d %d", &i, &j) == 2; ){
		double triv = 1e10;
		for(int a = i; a <= j; ++a){
			int x = sod(a);
			if(x / (double) a < triv) n = a, triv = x / (double) a;
		}
		printf("%d\n", n);
	}
	return 0;
}
Example #4
0
int main(void){
	int t; scanf("%d", &t);
	FORS(i, 0, 1, MAX) memonod[i] = memosod[i] = -1;
	for(int a, b, k; t-- && scanf("%d %d %d", &a, &b, &k) == 3; ){
		int start = ((a + k - 1) / k) * k;
		long long int g = 0, h = 0;
		++b;
		FORS(i, start, k, b){
			g += nod(i);
			h += sod(i);
		}
		printf("%lld %lld\n", g, h);
	}
Example #5
0
int main(void){
	clock_t ini = clock();
	long long ans = 0;
	list[ls++] = 1;
	for(int base = 2; ; ++base){
		int max_exp = int(ceil(63 * log(2) / log(base)));
		if(max_exp == 4) break;
		for(long long r = base * base, c = 2; c < max_exp; r *= base, ++c)
			if(r > 99 && sod(r) == base){
				printf("%lld = %d^%d\n", r, base, c);
				list[ls++] = r;
			}
	}
	std::sort(list, list + ls);
	ans = list[29];
	printf("Time spent: %.3lfs\n", ((double)(clock() - ini))/CLOCKS_PER_SEC);
	printf("Answer: %lld\n", ans);
	return 0;
}