Submission #22214

# Submission time Handle Problem Language Result Execution time Memory
22214 2017-04-30T01:14:05 Z sgc109(#1015, sgc109) None (KRIII5P_2) C++11
7 / 7
423 ms 9840 KB
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<=b;++i)
#define FOR(i,n) for(int i=0;i<n;++i)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define inp1(a) scanf("%d",&a)
#define inp2(a,b) scanf("%d%d",&a,&b)
#define inp3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define inp4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define inp5(a,b,c,d,e) scanf("%d%d%d%d%d",&a,&b,&c,&d,&e)
#define fastio() ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;	
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<vector<int> > vvi;
typedef pair<int,pair<int,int> > piii;
typedef vector<piii> viii;
const double EPSILON = 1e-9;
const double PI = acos(-1);
const int MOD = 1e9+7;
const int INF = 0x3c3c3c3c;
const long long INFL = 0x3c3c3c3c3c3c3c3c;
const int MAX_N = 102;

int N,P;
ll A[1000003];
ll sum[1003];
ll go(int x, int n){
	if(!x) return 0;
	if(n==0) return 1;
	if(n%2){
		ll tmp = go(x,(n-1)/2);
		return (x*tmp*tmp)%P;
	}
	ll tmp = go(x,n/2);
	return (tmp*tmp)%P;
}

int main() {
	inp2(N,P);
	FOR(i,N+1) scanf("%lld",A+i);
	if(P==1){
		printf("%lld",A[N]);
		return 0;
	}
	FOR(i,N+1) sum[i%(P-1)] += A[N-i];
	sum[0] -= A[N];
	FOR(i,P){
		ll ans = 0;
		FOR(j,P){
			ans = (ans + go(i, j) * sum[j]) % P;
		}
		printf("%lld\n",(ans+A[N])%P);
	}

	return 0;
}

Compilation message

pc.cpp: In function 'int main()':
pc.cpp:46:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  inp2(N,P);
           ^
pc.cpp:47:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  FOR(i,N+1) scanf("%lld",A+i);
                              ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9840 KB Output is correct
2 Correct 0 ms 9840 KB Output is correct
3 Correct 0 ms 9840 KB Output is correct
4 Correct 0 ms 9840 KB Output is correct
5 Correct 0 ms 9840 KB Output is correct
6 Correct 229 ms 9840 KB Output is correct
7 Correct 219 ms 9840 KB Output is correct
8 Correct 216 ms 9840 KB Output is correct
9 Correct 213 ms 9840 KB Output is correct
10 Correct 209 ms 9840 KB Output is correct
11 Correct 119 ms 9840 KB Output is correct
12 Correct 163 ms 9840 KB Output is correct
13 Correct 43 ms 9840 KB Output is correct
14 Correct 13 ms 9840 KB Output is correct
15 Correct 29 ms 9840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9840 KB Output is correct
2 Correct 0 ms 9840 KB Output is correct
3 Correct 0 ms 9840 KB Output is correct
4 Correct 0 ms 9840 KB Output is correct
5 Correct 0 ms 9840 KB Output is correct
6 Correct 229 ms 9840 KB Output is correct
7 Correct 219 ms 9840 KB Output is correct
8 Correct 216 ms 9840 KB Output is correct
9 Correct 213 ms 9840 KB Output is correct
10 Correct 209 ms 9840 KB Output is correct
11 Correct 119 ms 9840 KB Output is correct
12 Correct 163 ms 9840 KB Output is correct
13 Correct 43 ms 9840 KB Output is correct
14 Correct 13 ms 9840 KB Output is correct
15 Correct 29 ms 9840 KB Output is correct
16 Correct 183 ms 9840 KB Output is correct
17 Correct 213 ms 9840 KB Output is correct
18 Correct 166 ms 9840 KB Output is correct
19 Correct 169 ms 9840 KB Output is correct
20 Correct 186 ms 9840 KB Output is correct
21 Correct 419 ms 9840 KB Output is correct
22 Correct 409 ms 9840 KB Output is correct
23 Correct 423 ms 9840 KB Output is correct
24 Correct 393 ms 9840 KB Output is correct
25 Correct 383 ms 9840 KB Output is correct
26 Correct 316 ms 9840 KB Output is correct
27 Correct 333 ms 9840 KB Output is correct
28 Correct 239 ms 9840 KB Output is correct
29 Correct 193 ms 9840 KB Output is correct
30 Correct 209 ms 9840 KB Output is correct