标签:
Time Limit: 8000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1697 Accepted Submission(s): 760
1 //2016.9.12 2 #include <iostream> 3 #include <cstdio> 4 #include <cstring> 5 #define N 100005 6 7 using namespace std; 8 9 int nu[N], book[N]; 10 11 int main() 12 { 13 long long ans; 14 int T, kase = 0, q, mod, op; 15 scanf("%d", &T); 16 while(T--) 17 { 18 ans = 1; 19 memset(book, true, sizeof(book)); 20 printf("Case #%d:\n", ++kase); 21 scanf("%d%d", &q, &mod); 22 for(int i = 1; i <= q; i++) 23 { 24 scanf("%d%d", &op, &nu[i]); 25 if(op == 1) 26 { 27 ans *= nu[i]; 28 ans %= mod; 29 } 30 else 31 { 32 book[nu[i]] = false; 33 book[i] = false; 34 ans = 1; 35 for(int j = 1; j < i; j++) 36 { 37 if(book[j])ans = (ans*nu[j])%mod; 38 } 39 } 40 printf("%lld\n", ans); 41 } 42 } 43 44 return 0; 45 }
标签:
原文地址:http://www.cnblogs.com/Penn000/p/5868427.html