数学_大数求模(HDU_1021)
公式: (a+b)%k = (a%k + b%k)%k
(a-b)%k = (a%k - b%k)%k
#include <stdio.h> #include <string.h> #define M 1000000 #define MOD 3 int map[M] = {7,11}; void init() { for(int i=2; i<M; i++) { map[i] = (map[i-2] % MOD + map[i-1] % MOD) % MOD; } } int main(int argc, char* argv[]) { #ifdef __MYLOCAL freopen("in.txt","r",stdin); #endif int n; init(); while(scanf("%d",&n) != EOF) { printf("%s\n",map[n]%MOD == 0 ? "yes" : "no"); } return 0; }