結果
| 問題 | No.1594 Three Classes |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-09 21:50:06 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 2,000 ms |
| コード長 | 670 bytes |
| コンパイル時間 | 495 ms |
| コンパイル使用メモリ | 47,104 KB |
| 最終ジャッジ日時 | 2025-01-22 21:28:09 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | scanf("%u", &N);
| ~~~~~^~~~~~~~~~
main.cpp:9:37: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | for(int i = 0; i < N; ++i) scanf("%u", &E[i]);
| ~~~~~^~~~~~~~~~~~~
ソースコード
#include<cstdio>
#include<vector>
using namespace std;
int main(){
unsigned N;
scanf("%u", &N);
vector<unsigned> E(N);
for(int i = 0; i < N; ++i) scanf("%u", &E[i]);
unsigned three = 1;
for (unsigned i = 0; i < N; i++){
three *= 3;
}
unsigned lowest, power[3];
for (unsigned bit = 0; bit < three; bit++)
{
power[0] = power[1] = power[2] = 0;
for (unsigned _i = bit, j = 0; j < N; _i /= 3, j++)
{
power[_i%3] += E[j];
}
if(power[0] == power[1] && power[1] == power[2]){
printf("Yes\n");
return 0;
}
}
printf("No\n");
return 0;
}