結果
| 問題 | No.607 開通777年記念 | 
| コンテスト | |
| ユーザー |  extelo | 
| 提出日時 | 2017-12-08 12:14:54 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 98 ms / 2,000 ms | 
| コード長 | 1,153 bytes | 
| コンパイル時間 | 303 ms | 
| コンパイル使用メモリ | 28,672 KB | 
| 最終ジャッジ日時 | 2025-01-05 04:57:48 | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 10 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:38:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   38 |   scanf("%d %d", &num_train, &num_station);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:47:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   47 |         scanf("%d", &train[i].n);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:51:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   51 |         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;
     if(sum == 777){
      judge = 1;
      break;
    }
    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;   
}
            
            
            
        