結果
| 問題 |
No.854 公平なりんご分配
|
| コンテスト | |
| ユーザー |
leaf_1415
|
| 提出日時 | 2019-07-26 22:14:09 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,310 bytes |
| コンパイル時間 | 604 ms |
| コンパイル使用メモリ | 63,596 KB |
| 実行使用メモリ | 88,788 KB |
| 最終ジャッジ日時 | 2024-07-02 07:37:27 |
| 合計ジャッジ時間 | 11,539 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 50 TLE * 1 -- * 41 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:31:17: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat=]
31 | scanf("%d", &n);
| ~^ ~~
| | |
| | long long int*
| int*
| %lld
main.cpp:32:45: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat=]
32 | for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
| ~^ ~~~~~
| | |
| | long long int*
| int*
| %lld
main.cpp:31:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
31 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:32:42: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
32 | 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>
#define llint long long
using namespace std;
llint n, Q;
llint a[100005];
int d[325][100005];
int sum[325][100005];
int need[325];
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;
for(int i = 0; i < m; i++) need[i] = 0;
for(int i = 0; i < m; i++){
if(pvec[i] > t) break;
while(t % pvec[i] == 0){
need[i]++;
t /= pvec[i];
}
}
if(t > 1){
printf("NO\n");
continue;
}
bool flag = true;
for(int i = 0; i < m; i++){
if(need[i] > sum[i][r]-sum[i][l-1]){
flag = false;
break;
}
}
if(flag) printf("Yes\n");
else printf("NO\n");
}
return 0;
}
leaf_1415