Submission #410903


Source Code Expand

// include {{{
#include <cstdio>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
//#include <deque>
#include <stack>
#include <queue>
//#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <numeric>
//#include <complex>
// }}}
using namespace std;
// macro {{{
typedef long long ll;
typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0,__end=(n);i<__end;++i)
#define REP(i,j,k) for(int i=j,__end=(k);i<__end;++i)
//#define foreach(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();++it)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define priority_queue_greater(T) priority_queue< T, vector<T>, greater<T> >
#define F first
#define S second
// BEGIN CUT HERE {{{
// convert {{{
template<typename T> T fromString(string& s){
  T res;
  std::istringstream is(s);
  is >> res;
  return res;
}
template<typename T> string toString(T& v){
  stringstream ss;
  ss << v;
  return ss.str();
} // }}}
// inspect {{{
string inspect( string str );
string inspect( bool str );
template<typename T> string inspect( T v );
template<typename T,typename U> string inspect( pair<T,U> v );
template<typename T> string inspect( vector<T> v );
string inspect( string str ){
  return "\"" + str + "\"";
}
string inspect( bool flag ){
  return flag ? "True" : "False";
}
template<typename T> string inspect( T v ){
  return toString<T>( v );
}
template<typename T,typename U> string inspect( pair<T,U> v ){
  return "(" + inspect(v.first) + "," + inspect(v.second) + ")";
}
template<typename T> string inspect( vector<T> v ){
  string res = "[";
  rep(i,v.size()){
    if( i != 0 ){ res += ","; }
    res += inspect( v[i] );
  }
  return res + "]";
}
// }}}
// puts {{{
void puts() {};
template<class First, class... Rest>
void puts(const First& first, const Rest&... rest ){
  cout << inspect(first) << endl;
  puts(rest...);
}
// }}}
// END CUT HERE }}}
// }}}

ll year, month;
int main(){
  while(cin >> year >> month){
    ll count = year * 12 + month;
    ll l = 2013, r = 10000000000;
    ll thisMonth;

    rep(loop,100){
      ll m = (l + r) / 2;
      ll diff = m - 2013;
      ll sub = diff * (1 + diff) / 2;
      ll now = m * 12 + sub;
      thisMonth = count - now;

      if(thisMonth <= 0){
        r = m;
      } else {
        l = m;
      }
    }
    cout << l << " " << thisMonth << endl;
  }
  return 0;
}

Submission Info

Submission Time
Task B - 13月
User jimon
Language C++ (G++ 4.6.4)
Score 100
Code Size 2557 Byte
Status AC
Exec Time 31 ms
Memory 1152 KiB

Compile Error

./Main.cpp:73:28: warning: variadic templates only available with -std=c++0x or -std=gnu++0x [enabled by default]
./Main.cpp:74:46: warning: variadic templates only available with -std=c++0x or -std=gnu++0x [enabled by default]

Judge Result

Set Name Small Large
Score / Max Score 50 / 50 50 / 50
Status
AC × 19
AC × 35
Set Name Test Cases
Small 01-max-small, 01-random-small01, 01-random-small02, 01-random-small03, 01-random-small04, 01-random-small05, 01-random-small06, 01-random-small07, 01-random-small08, 01-random-small09, 01-random-small10, 01-random-small11, 01-random-small12, 01-random-small13, 01-random-small14, 01-random-small15, 00-sample1, 00-sample2, 00-sample3
Large 00-sample1, 00-sample2, 00-sample3, 01-max-small, 01-random-small01, 01-random-small02, 01-random-small03, 01-random-small04, 01-random-small05, 01-random-small06, 01-random-small07, 01-random-small08, 01-random-small09, 01-random-small10, 01-random-small11, 01-random-small12, 01-random-small13, 01-random-small14, 01-random-small15, 10-max-large, 11-random-large01, 11-random-large02, 11-random-large03, 11-random-large04, 11-random-large05, 11-random-large06, 11-random-large07, 11-random-large08, 11-random-large09, 11-random-large10, 11-random-large11, 11-random-large12, 11-random-large13, 11-random-large14, 11-random-large15
Case Name Status Exec Time Memory
00-sample1 AC 31 ms 1112 KiB
00-sample2 AC 30 ms 1052 KiB
00-sample3 AC 30 ms 1108 KiB
01-max-small AC 31 ms 1116 KiB
01-random-small01 AC 30 ms 1048 KiB
01-random-small02 AC 28 ms 1048 KiB
01-random-small03 AC 28 ms 1048 KiB
01-random-small04 AC 28 ms 1056 KiB
01-random-small05 AC 28 ms 1044 KiB
01-random-small06 AC 28 ms 1052 KiB
01-random-small07 AC 27 ms 1056 KiB
01-random-small08 AC 28 ms 1048 KiB
01-random-small09 AC 28 ms 1044 KiB
01-random-small10 AC 28 ms 1052 KiB
01-random-small11 AC 28 ms 1048 KiB
01-random-small12 AC 28 ms 1044 KiB
01-random-small13 AC 28 ms 1088 KiB
01-random-small14 AC 28 ms 1052 KiB
01-random-small15 AC 27 ms 1152 KiB
10-max-large AC 27 ms 1148 KiB
11-random-large01 AC 28 ms 1052 KiB
11-random-large02 AC 28 ms 1040 KiB
11-random-large03 AC 28 ms 1052 KiB
11-random-large04 AC 28 ms 1048 KiB
11-random-large05 AC 28 ms 1040 KiB
11-random-large06 AC 28 ms 1044 KiB
11-random-large07 AC 28 ms 1112 KiB
11-random-large08 AC 28 ms 1044 KiB
11-random-large09 AC 27 ms 1136 KiB
11-random-large10 AC 28 ms 1044 KiB
11-random-large11 AC 28 ms 1048 KiB
11-random-large12 AC 28 ms 1048 KiB
11-random-large13 AC 28 ms 1048 KiB
11-random-large14 AC 28 ms 1048 KiB
11-random-large15 AC 28 ms 1044 KiB