結果
問題 | No.16 累乗の加算 |
ユーザー |
![]() |
提出日時 | 2015-06-04 19:25:11 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,005 bytes |
コンパイル時間 | 643 ms |
コンパイル使用メモリ | 69,516 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 04:56:02 |
合計ジャッジ時間 | 1,180 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
ソースコード
#include <iostream>#include <iomanip>#include <algorithm>#include <math.h>#include <string>#include <list>/////////#define REP(i, x, n) for(int i = x; i < n; i++)#define rep(i,n) REP(i,0,n)#define P(p) cout<<(p)<<endl;/////////typedef long long LL;typedef long double LD;/////////using namespace::std;/////////const int mod = 1000003;//int x,N;LL xpow[27];void ppp(){xpow[0] = x;for(int i=1;i<27;++i) {xpow[i] = (xpow[i-1] * xpow[i-1])%mod;}}int f(int a){if( a == 0){return 1;}LL ans = 1;int temp = a;int count = 0;while(temp != 0){if(temp%2 == 1){ans = (ans * xpow[count]) % mod;}temp /= 2;++count;}return (int)ans;}int main(void){cin.tie(0);ios::sync_with_stdio(false);cout << fixed;////cout << setprecision(6);//cin>>x>>N;//x[1,100]整数//N[1,100]int a[100];rep(i,N){cin>>a[i];//a[0,10^8]}////ppp();int sum=0;rep(i,N){sum = (sum + f(a[i]) ) % mod;}P(sum);return 0;}