NYOJ 205 求余数 (大数模拟求余)

原题链接

经典题,模拟求余。

附ac代码:

#include <stdio.h>
#include <string.h>
#define MAX 1000000 + 2
char s[MAX];

//模拟取余
int Simu(int n){
	int t = 0, len = strlen(s);
	for(int i = 0; i != len; ++i){
		t = t * 10 + s[i] - '0';
		t %= n;
	}
	return t;
}

int main(){
	int t, x;
	scanf("%d", &t);
	while(t-- && scanf("%s", s))
		printf("%d\n", Simu(10003));	
	return 0;
}


posted on 2014-02-14 20:18  长木Qiu  阅读(178)  评论(0)    收藏  举报