結果
| 問題 |
No.147 試験監督(2)
|
| コンテスト | |
| ユーザー |
latte0119
|
| 提出日時 | 2016-05-26 00:15:20 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,409 bytes |
| コンパイル時間 | 910 ms |
| コンパイル使用メモリ | 92,464 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-07 14:32:54 |
| 合計ジャッジ時間 | 3,979 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 4 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:93:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
93 | scanf("%d", &N);
| ~~~~~^~~~~~~~~~
main.cpp:99:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
99 | scanf("%lld%s", &C, D);
| ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<cstdio>
#include<algorithm>
#include<vector>
#include<iostream>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
#include<map>
#include<set>
#include<sstream>
#include<bitset>
#include<numeric>
#include<climits>
#include<cassert>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
template<typename A,typename B>inline void chmin(A &a, B b) { if (a > b)a = b; }
template<typename A,typename B>inline void chmax(A &a, B b) { if (a < b)a = b; }
template<int MOD>
class kitamasa_hou {
int K;
vector<long long>A, D;
vector<long long>advance(vector<long long>x) {
rotate(x.begin(), x.end() - 1, x.end());
for (int i = 1; i<x.size(); i++)x[i] = (x[i] + x[0] * D[i]) % MOD;
return x;
}
vector<long long>advance2(vector<long long>x) {
vector<long long>y = x, z(K, 0);
for (int i = 0; i<K; i++) {
for (int j = 0; j<K; j++)z[j] = (z[j] + x[j] * y[i]) % MOD;
x = advance(x);
}
return z;
}
public:
kitamasa_hou(int K, vector<long long>A, vector<long long>D)
:K(K), A(A.begin(), A.end()), D(D.begin(), D.end()) {}
ll query(ll N) {
assert(K);
vector<long long>x = D;
if (N<K)return A[N];
ll n = K;
int p;
[&]() {
for (;; n++) {
for (p = 0; N >> p; p++)if ((N >> p) == n)return;
x = advance(x);
}
}();
for (p--; p >= 0; p--) {
x = advance2(x);
if (N >> p & 1)x = advance(x);
}
ll ret = 0;
for (int i = 0; i<K; i++)ret = (ret + x[i] * A[i]) % MOD;
return ret;
}
};
const int mod = 1000000007;
ll modpow(ll n,ll m){
if(n==0)return 0;
ll ret = 1;
while (m) {
if (m & 1)ret = ret*n%mod;
n = n*n%mod;
m >>= 1;
}
return ret;
}
int main() {
ll ans = 1;
int N;
scanf("%d", &N);
kitamasa_hou<mod>fib(2, { 1,2 }, { 1,1 });
for (int i = 0; i < N;i++) {
ll C;
char D[210];
scanf("%lld%s", &C, D);
ll d = 0;
for (int j = 0; D[j]; j++)d = (d * 10 + D[j] - '0') % (mod-1);
ans = ans*modpow(fib.query(C), d) % mod;
cout<<fib.query(C)<<endl;
}
cout << ans << endl;
return 0;
}
latte0119