[HDU] [1212] Big Number

Problem Description

Loading...

Problem Analysis

Another problem about the congruence theorem
Essentially, it still uses a string to simulate a Big Number

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#include<stdio.h>
#include<string.h>
int main() {
	char s[1200];
	int b,l;
	int i;
	__int64 m;
	while(scanf("%s %d",s,&b)!=EOF) {
		l=strlen(s);
		for(i=m=0; i<l; i++) {
			m=(m*10+s[i]-'0')%b;
		}
		printf("%I64d\n",m);
	}
	return 0;
}

Problem link: 【杭电】[1212]Big Number

Loading...