結果
問題 | No.607 開通777年記念 |
ユーザー |
![]() |
提出日時 | 2017-12-08 12:13:35 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,096 bytes |
コンパイル時間 | 312 ms |
コンパイル使用メモリ | 28,416 KB |
最終ジャッジ日時 | 2025-01-05 04:57:46 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 WA * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:34:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 34 | scanf("%d %d", &num_train, &num_station); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:43:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 43 | scanf("%d", &train[i].n); | ~~~~~^~~~~~~~~~~~~~~~~~~ main.cpp:47:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 47 | scanf("%d", &tmp); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <stdio.h> class Train { public: int n; }; int check(Train *train, int num_train, int judge) { for(int i=0; i<num_train; i++){ int sum = train[i].n; for(int j=i+1; j<num_train; j++){ sum += train[j].n; if(sum < 777){ continue; } else if(sum >= 777){ break; } } if(sum == 777){ judge = 1; break; } } return judge; } int main(void) { int num_train, num_station; scanf("%d %d", &num_train, &num_station); //printf("%d %d\n", num_train, num_station); Train train[num_train]; int judge=0; for(int s=0; s<num_station; s++){ for(int i=0; i<num_train; i++){ if(s==0){ scanf("%d", &train[i].n); //printf("%d\n", train[i].n); } else { int tmp; scanf("%d", &tmp); train[i].n += tmp; //printf("%d\n", train[i].n); } } judge = check(train, num_train, judge); if(judge == 1){ break; } else { continue; } } if(judge == 0){ printf("NO\n"); } else { printf("YES\n"); } return 0; }