結果
問題 |
No.896 友達以上恋人未満
|
ユーザー |
![]() |
提出日時 | 2018-01-23 23:04:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,118 bytes |
コンパイル時間 | 183 ms |
コンパイル使用メモリ | 30,080 KB |
最終ジャッジ日時 | 2025-01-05 07:48:32 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 2 RE * 2 |
other | WA * 1 RE * 6 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:21:44: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘ll*’ {aka ‘long long int*’} [-Wformat=] 21 | for(int i = 0; i < m; i++) scanf("%d", x+i); | ~^ ~~~ | | | | int* ll* {aka long long int*} | %lld main.cpp:22:44: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘ll*’ {aka ‘long long int*’} [-Wformat=] 22 | for(int i = 0; i < m; i++) scanf("%d", y+i); | ~^ ~~~ | | | | int* ll* {aka long long int*} | %lld main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%d%d%d%d%d%d%d",&m,&n,&mx,&ax,&my,&ay,&mod); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:21:41: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 21 | for(int i = 0; i < m; i++) scanf("%d", x+i); | ~~~~~^~~~~~~~~~~ main.cpp:22:41: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 22 | for(int i = 0; i < m; i++) scanf("%d", y+i); | ~~~~~^~~~~~~~~~~ main.cpp:37:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 37 | scanf("%d", &q); |
ソースコード
// naive solution #include <cstdio> #include <cassert> using namespace std; typedef long long ll; #define N (1<<23) int m, n, mx, ax, my, ay, mod, q; ll x[N], y[N], z[N]; bool prime[N]; int main(){ scanf("%d%d%d%d%d%d%d",&m,&n,&mx,&ax,&my,&ay,&mod); assert(1<=m&&m<=100); assert(m<=n&&n<=10000000); assert(1<=mod&&mod<=1<<23); assert(__builtin_popcount(mod)==1); assert(0<=mx&&mx<mod); assert(0<=ax&&ax<mod); assert(0<=my&&my<mod); assert(0<=ay&&ay<mod); 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 = m; i < n; i++){ x[i] = (x[i-1]*mx+ax)&(mod-1); y[i] = (y[i-1]*my+ay)&(mod-1); } for(int i = 0; i < n; i++){ z[x[i]] += y[i]; printf("%lld %lld\n", x[i], y[i]); } for(int i = 2; i*i<N; i++){ if(prime[i]) continue; for(int j = i*i; j<N; j+=i){ prime[j] = true; } } scanf("%d", &q); assert(1<=q&&q<=100000); while(q--){ int a, b; scanf("%d%d",&a,&b); assert(1<=a&&(ll)a<=1000000000/b&&a*b<=1000000000); ll res = 0; for(ll i = 1; i < mod; i++){ if(i%a==0&&i%(a*b)!=0) res += z[i]; } printf("%lld\n", res); } }