AtCoder Regular Contest 002

Submission #1047872

Source codeソースコード

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

bool leap(int y) {
  if (y % 400 == 0) {
    return true;
  }
  if (y % 100 == 0) {
    return false;
  }
  if (y % 4 == 0) {
    return true;
  }
  return false;
}

//             1   2   3   4   5   6   7   8   9  10  11  12
vi days = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int last_day(int y, int m) {
  if (leap(y) && m == 2) {
    return 29;
  }
  return days[m];
}

tuple<int, int, int> next_day(int y, int m, int d) {
  int ld = last_day(y, m);
  if (d == ld) {
    if (m == 12) {
      return make_tuple(y+1, 1, 1);
    }
    return make_tuple(y, m+1, 1);
  }
  return make_tuple(y, m, d+1);
}

int main() {
  int y, m, d;
  scanf("%d/%d/%d", &y, &m, &d);
  while (true) {
    if (y % (m * d) == 0) {
      printf("%d/%02d/%02d\n", y, m, d);
      return 0;
    }
    tie(y, m, d) = next_day(y, m, d);
  }

  return 0;
}

Submission

Task問題 B - 割り切れる日付
User nameユーザ名 cyglef
Created time投稿日時
Language言語 C++11 (GCC 4.8.1)
Status状態 AC
Score得点 100
Source lengthソースコード長 1788 Byte
File nameファイル名
Exec time実行時間 20 ms
Memory usageメモリ使用量 932 KB

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:74:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d/%d/%d", &y, &m, &d);
^

Test case

Set

Set name Score得点 / Max score Cases
All 100 / 100 00_retmax.txt,00_retmin.txt,00_sample_00.txt,00_sample_01.txt,00_sample_02.txt,01_rnd_00.txt,01_rnd_01.txt,01_rnd_02.txt,01_rnd_03.txt,01_rnd_04.txt,01_rnd_05.txt,01_rnd_06.txt,01_rnd_07.txt,01_rnd_08.txt,01_rnd_09.txt,01_rnd_10.txt,01_rnd_11.txt,01_rnd_12.txt,01_rnd_13.txt,01_rnd_14.txt,01_rnd_15.txt,01_rnd_16.txt,01_rnd_17.txt,01_rnd_18.txt,01_rnd_19.txt,02_last_01_0_0.txt,02_last_01_0_1.txt,02_last_01_1_0.txt,02_last_01_1_1.txt,02_last_01_2_0.txt,02_last_01_2_1.txt,02_last_01_3_0.txt,02_last_01_3_1.txt,02_last_02_0_0.txt,02_last_02_0_1.txt,02_last_02_1_0.txt,02_last_02_1_1.txt,02_last_02_2_0.txt,02_last_02_2_1.txt,02_last_02_3_0.txt,02_last_02_3_1.txt,02_last_03_0_0.txt,02_last_03_0_1.txt,02_last_03_1_0.txt,02_last_03_1_1.txt,02_last_03_2_0.txt,02_last_03_2_1.txt,02_last_03_3_0.txt,02_last_03_3_1.txt,02_last_04_0_0.txt,02_last_04_0_1.txt,02_last_04_1_0.txt,02_last_04_1_1.txt,02_last_04_2_0.txt,02_last_04_2_1.txt,02_last_04_3_0.txt,02_last_04_3_1.txt,02_last_05_0_0.txt,02_last_05_0_1.txt,02_last_05_1_0.txt,02_last_05_1_1.txt,02_last_05_2_0.txt,02_last_05_2_1.txt,02_last_05_3_0.txt,02_last_05_3_1.txt,02_last_06_0_0.txt,02_last_06_0_1.txt,02_last_06_1_0.txt,02_last_06_1_1.txt,02_last_06_2_0.txt,02_last_06_2_1.txt,02_last_06_3_0.txt,02_last_06_3_1.txt,02_last_07_0_0.txt,02_last_07_0_1.txt,02_last_07_1_0.txt,02_last_07_1_1.txt,02_last_07_2_0.txt,02_last_07_2_1.txt,02_last_07_3_0.txt,02_last_07_3_1.txt,02_last_08_0_0.txt,02_last_08_0_1.txt,02_last_08_1_0.txt,02_last_08_1_1.txt,02_last_08_2_0.txt,02_last_08_2_1.txt,02_last_08_3_0.txt,02_last_08_3_1.txt,02_last_09_0_0.txt,02_last_09_0_1.txt,02_last_09_1_0.txt,02_last_09_1_1.txt,02_last_09_2_0.txt,02_last_09_2_1.txt,02_last_09_3_0.txt,02_last_09_3_1.txt,02_last_10_0_0.txt,02_last_10_0_1.txt,02_last_10_1_0.txt,02_last_10_1_1.txt,02_last_10_2_0.txt,02_last_10_2_1.txt,02_last_10_3_0.txt,02_last_10_3_1.txt,02_last_11_0_0.txt,02_last_11_0_1.txt,02_last_11_1_0.txt,02_last_11_1_1.txt,02_last_11_2_0.txt,02_last_11_2_1.txt,02_last_11_3_0.txt,02_last_11_3_1.txt,02_last_12_0_0.txt,02_last_12_0_1.txt,02_last_12_1_0.txt,02_last_12_1_1.txt,02_last_12_2_0.txt,02_last_12_2_1.txt,02_last_12_3_0.txt,02_last_12_3_1.txt,03_special_01.txt,03_special_02.txt,03_special_03.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00_retmax.txt AC 18 ms 676 KB
00_retmin.txt AC 16 ms 800 KB
00_sample_00.txt AC 17 ms 804 KB
00_sample_01.txt AC 18 ms 804 KB
00_sample_02.txt AC 18 ms 796 KB
01_rnd_00.txt AC 18 ms 804 KB
01_rnd_01.txt AC 18 ms 848 KB
01_rnd_02.txt AC 19 ms 800 KB
01_rnd_03.txt AC 18 ms 796 KB
01_rnd_04.txt AC 18 ms 796 KB
01_rnd_05.txt AC 18 ms 800 KB
01_rnd_06.txt AC 17 ms 668 KB
01_rnd_07.txt AC 17 ms 804 KB
01_rnd_08.txt AC 17 ms 796 KB
01_rnd_09.txt AC 18 ms 804 KB
01_rnd_10.txt AC 18 ms 804 KB
01_rnd_11.txt AC 18 ms 804 KB
01_rnd_12.txt AC 18 ms 804 KB
01_rnd_13.txt AC 18 ms 676 KB
01_rnd_14.txt AC 18 ms 800 KB
01_rnd_15.txt AC 18 ms 800 KB
01_rnd_16.txt AC 19 ms 804 KB
01_rnd_17.txt AC 18 ms 716 KB
01_rnd_18.txt AC 17 ms 804 KB
01_rnd_19.txt AC 18 ms 804 KB
02_last_01_0_0.txt AC 18 ms 804 KB
02_last_01_0_1.txt AC 18 ms 800 KB
02_last_01_1_0.txt AC 16 ms 804 KB
02_last_01_1_1.txt AC 18 ms 804 KB
02_last_01_2_0.txt AC 18 ms 928 KB
02_last_01_2_1.txt AC 18 ms 800 KB
02_last_01_3_0.txt AC 18 ms 804 KB
02_last_01_3_1.txt AC 18 ms 800 KB
02_last_02_0_0.txt AC 18 ms 804 KB
02_last_02_0_1.txt AC 18 ms 676 KB
02_last_02_1_0.txt AC 18 ms 804 KB
02_last_02_1_1.txt AC 19 ms 804 KB
02_last_02_2_0.txt AC 18 ms 800 KB
02_last_02_2_1.txt AC 19 ms 844 KB
02_last_02_3_0.txt AC 20 ms 732 KB
02_last_02_3_1.txt AC 19 ms 924 KB
02_last_03_0_0.txt AC 19 ms 800 KB
02_last_03_0_1.txt AC 17 ms 804 KB
02_last_03_1_0.txt AC 18 ms 800 KB
02_last_03_1_1.txt AC 18 ms 676 KB
02_last_03_2_0.txt AC 19 ms 800 KB
02_last_03_2_1.txt AC 18 ms 804 KB
02_last_03_3_0.txt AC 18 ms 800 KB
02_last_03_3_1.txt AC 16 ms 804 KB
02_last_04_0_0.txt AC 17 ms 800 KB
02_last_04_0_1.txt AC 18 ms 800 KB
02_last_04_1_0.txt AC 18 ms 676 KB
02_last_04_1_1.txt AC 19 ms 800 KB
02_last_04_2_0.txt AC 18 ms 796 KB
02_last_04_2_1.txt AC 18 ms 720 KB
02_last_04_3_0.txt AC 16 ms 676 KB
02_last_04_3_1.txt AC 18 ms 928 KB
02_last_05_0_0.txt AC 18 ms 676 KB
02_last_05_0_1.txt AC 18 ms 804 KB
02_last_05_1_0.txt AC 18 ms 924 KB
02_last_05_1_1.txt AC 16 ms 800 KB
02_last_05_2_0.txt AC 17 ms 676 KB
02_last_05_2_1.txt AC 19 ms 904 KB
02_last_05_3_0.txt AC 18 ms 920 KB
02_last_05_3_1.txt AC 16 ms 804 KB
02_last_06_0_0.txt AC 18 ms 804 KB
02_last_06_0_1.txt AC 16 ms 800 KB
02_last_06_1_0.txt AC 18 ms 796 KB
02_last_06_1_1.txt AC 18 ms 804 KB
02_last_06_2_0.txt AC 18 ms 676 KB
02_last_06_2_1.txt AC 18 ms 676 KB
02_last_06_3_0.txt AC 17 ms 804 KB
02_last_06_3_1.txt AC 19 ms 924 KB
02_last_07_0_0.txt AC 17 ms 804 KB
02_last_07_0_1.txt AC 17 ms 800 KB
02_last_07_1_0.txt AC 18 ms 676 KB
02_last_07_1_1.txt AC 18 ms 800 KB
02_last_07_2_0.txt AC 17 ms 804 KB
02_last_07_2_1.txt AC 16 ms 800 KB
02_last_07_3_0.txt AC 18 ms 804 KB
02_last_07_3_1.txt AC 18 ms 804 KB
02_last_08_0_0.txt AC 18 ms 804 KB
02_last_08_0_1.txt AC 17 ms 804 KB
02_last_08_1_0.txt AC 18 ms 804 KB
02_last_08_1_1.txt AC 17 ms 924 KB
02_last_08_2_0.txt AC 16 ms 676 KB
02_last_08_2_1.txt AC 18 ms 844 KB
02_last_08_3_0.txt AC 18 ms 932 KB
02_last_08_3_1.txt AC 18 ms 800 KB
02_last_09_0_0.txt AC 18 ms 928 KB
02_last_09_0_1.txt AC 18 ms 928 KB
02_last_09_1_0.txt AC 16 ms 796 KB
02_last_09_1_1.txt AC 18 ms 804 KB
02_last_09_2_0.txt AC 18 ms 928 KB
02_last_09_2_1.txt AC 18 ms 804 KB
02_last_09_3_0.txt AC 16 ms 800 KB
02_last_09_3_1.txt AC 18 ms 800 KB
02_last_10_0_0.txt AC 18 ms 800 KB
02_last_10_0_1.txt AC 18 ms 804 KB
02_last_10_1_0.txt AC 18 ms 800 KB
02_last_10_1_1.txt AC 17 ms 804 KB
02_last_10_2_0.txt AC 18 ms 800 KB
02_last_10_2_1.txt AC 18 ms 720 KB
02_last_10_3_0.txt AC 18 ms 804 KB
02_last_10_3_1.txt AC 18 ms 800 KB
02_last_11_0_0.txt AC 18 ms 804 KB
02_last_11_0_1.txt AC 18 ms 804 KB
02_last_11_1_0.txt AC 16 ms 928 KB
02_last_11_1_1.txt AC 18 ms 800 KB
02_last_11_2_0.txt AC 18 ms 676 KB
02_last_11_2_1.txt AC 18 ms 800 KB
02_last_11_3_0.txt AC 18 ms 804 KB
02_last_11_3_1.txt AC 17 ms 804 KB
02_last_12_0_0.txt AC 16 ms 804 KB
02_last_12_0_1.txt AC 18 ms 804 KB
02_last_12_1_0.txt AC 16 ms 804 KB
02_last_12_1_1.txt AC 18 ms 804 KB
02_last_12_2_0.txt AC 16 ms 928 KB
02_last_12_2_1.txt AC 17 ms 844 KB
02_last_12_3_0.txt AC 18 ms 920 KB
02_last_12_3_1.txt AC 16 ms 800 KB
03_special_01.txt AC 18 ms 804 KB
03_special_02.txt AC 18 ms 676 KB
03_special_03.txt AC 18 ms 800 KB