2019-05-27
17:52:01
Come on! ! !
We should carefully look at the question time, it is easy to forget the last 10 000%
#include <bits/stdc++.h> using namespace std; int main() { int t, n; // cin >> t >> n; scanf("%d", &t); while (t--) { // cin >> n; scanf("%d", &n); long long sum = 0; for (int i = 1,j = 1;i <= n; i++, j += 2) { sum += j; sum %= 10000; } cout << sum << endl; } return 0; }
Another approach: use physical formula
#include <bits/stdc++.h> using namespace std; int main() { int n,t; int v0=1,v; int s; while(cin>>n) { while(n--) { cin>>t; v=v0+2*(t-1); s=((v+v0)*t/2)%10000; cout<<s<<endl; } } return 0; }