結果
| 問題 |
No.896 友達以上恋人未満
|
| コンテスト | |
| ユーザー |
Lepton_s
|
| 提出日時 | 2018-02-24 01:20:34 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,520 bytes |
| コンパイル時間 | 674 ms |
| コンパイル使用メモリ | 67,484 KB |
| 最終ジャッジ日時 | 2025-01-05 08:47:33 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | TLE * 4 |
| other | TLE * 5 MLE * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:31:44: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘ll*’ {aka ‘long long int*’} [-Wformat=]
31 | for(int i = 0; i < m; i++) scanf("%d", x+i);
| ~^ ~~~
| | |
| int* ll* {aka long long int*}
| %lld
main.cpp:32:44: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘ll*’ {aka ‘long long int*’} [-Wformat=]
32 | for(int i = 0; i < m; i++) scanf("%d", y+i);
| ~^ ~~~
| | |
| int* ll* {aka long long int*}
| %lld
main.cpp:56:44: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘ll*’ {aka ‘long long int*’} [-Wformat=]
56 | for(int i = 0; i < m; i++) scanf("%d", a+i);
| ~^ ~~~
| | |
| int* ll* {aka long long int*}
| %lld
main.cpp:57:44: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘ll*’ {aka ‘long long int*’} [-Wformat=]
57 | for(int i = 0; i < m; i++) scanf("%d", b+i);
| ~^ ~~~
| | |
| int* ll* {aka long long int*}
| %lld
main.cpp:30:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with at
ソースコード
// naive
#include <cstdio>
#include <cassert>
#include <iostream>
#include <cstring>
using namespace std;
typedef long long ll;
#define N (1<<24)
#define M 100010
int m, n, mx, ax, my, ay, mod, mod2, mod3 = 1<<30;
ll x[M], y[M], z[N], a[M], b[M];
ll z2[N];
bool prime[N];
/*
ll solve(ll a, ll b){
b *= a;
return (a<mod?z[a]:0)-(b<mod?z[b]:0);
}
*/
ll solve2(ll a){
ll res = 0;
for(ll i = a; i < mod; i+=a){
res += z2[i];
}
return res;
}
int main(){
scanf("%d%d%d%d%d%d%d%d",&m,&n,&mx,&ax,&my,&ay,&mod,&mod2);
for(int i = 0; i < m; i++) scanf("%d", x+i);
for(int i = 0; i < m; i++) scanf("%d", y+i);
for(int i = 0; i < m; i++) z[x[i]] += y[i];
ll xx = x[m-1], yy = y[m-1];
for(int i = m; i < n; i++){
xx = (xx*mx+(ll)ax)&(mod-1);
yy = (yy*my+(ll)ay)&(mod-1);
z[xx] += yy;
}
for(int i = 2; i*i<mod; i++){
if(prime[i]) continue;
for(int j = i*i; j<mod; j+=i){
prime[j] = true;
}
}
memcpy(z2, z, sizeof(z));
/*
for(int i = 2; i < mod; i++){
if(prime[i]) continue;
for(int j = (mod-1)/i*i; j > 0; j-=i){
z[j/i] += z[j];
}
}
*/
for(int i = 0; i < m; i++) scanf("%d", a+i);
for(int i = 0; i < m; i++) scanf("%d", b+i);
ll res = 0;
for(int i = 0; i < m; i++){
ll r = solve2(a[i])-solve2(a[i]*b[i]);
printf("%lld\n", r);
(res+=r)&=mod3-1;
}
ll aa = a[m-1], bb = b[m-1];
for(int i = m; i < n; i++){
aa = ((aa*mx+(ll)ax+mod2-1)&(mod2-1))+1;
bb = ((bb*my+(ll)ay+mod2-1)&(mod2-1))+1;
(res+=solve2(aa)-solve2(aa*bb))&=mod3-1;
}
printf("%lld\n", res);
return 0;
}
Lepton_s