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