結果
問題 | No.854 公平なりんご分配 |
ユーザー |
![]() |
提出日時 | 2019-07-26 22:19:49 |
言語 | C++11 (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,338 bytes |
コンパイル時間 | 1,061 ms |
コンパイル使用メモリ | 74,732 KB |
実行使用メモリ | 91,740 KB |
最終ジャッジ日時 | 2024-07-02 07:40:27 |
合計ジャッジ時間 | 10,454 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 50 TLE * 1 -- * 41 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:32:17: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat=] 32 | scanf("%d", &n); | ~^ ~~ | | | | | long long int* | int* | %lld main.cpp:33:45: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat=] 33 | for(int i = 1; i <= n; i++) scanf("%d", &a[i]); | ~^ ~~~~~ | | | | | long long int* | int* | %lld main.cpp:32:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 32 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:33:42: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 33 | for(int i = 1; i <= n; i++) scanf("%d", &a[i]); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <stdio.h> #include <stdlib.h> #include <map> #define llint long long using namespace std; llint n, Q; llint a[100005]; int d[325][100005]; int sum[325][100005]; map<int, int> mp; bool prime[2005]; vector<llint> pvec; int main(void) { for(int i = 2; i < 55; i++){ if(prime[i]) continue; for(int j = 2*i; j < 2005; j+=i) prime[j] = true; } for(int i = 2; i < 2005; i++){ if(!prime[i]) pvec.push_back(i); } int m = pvec.size(); scanf("%d", &n); for(int i = 1; i <= n; i++) scanf("%d", &a[i]); for(int i = 0; i < m; i++){ for(int j = 1; j <= n; j++){ int t = a[j]; while(t % pvec[i] == 0){ d[i][j]++; t /= pvec[i]; } } for(int j = 1; j <= n; j++){ sum[i][j] = sum[i][j-1] + d[i][j]; } } cin >> Q; int p, l, r; for(int q = 0; q < Q; q++){ cin >> p >> l >> r; int t = p; mp.clear(); for(int i = 0; i < m; i++){ if(pvec[i] > t) break; while(t % pvec[i] == 0){ mp[i]++; t /= pvec[i]; } } if(t > 1){ printf("NO\n"); continue; } bool flag = true; for(auto it = mp.begin(); it != mp.end(); it++){ if(it->second > sum[it->first][r]-sum[it->first][l-1]){ flag = false; break; } } if(flag) printf("Yes\n"); else printf("NO\n"); } return 0; }