結果

問題 No.129 お年玉(2)
ユーザー koba-e964
提出日時 2015-06-10 18:02:15
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 590 bytes
コンパイル時間 666 ms
コンパイル使用メモリ 55,544 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-06 15:22:49
合計ジャッジ時間 1,366 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 4 WA * 42
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <iostream>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;

const int N = 10010;

int a[N];

int main(void){
  ll n,m;
  cin >> n >> m;
  n /= 1000;
  n %= m;
  // C(m, n)
  REP(i, 0, n) {
    a[i] = m - i;
  }
  REP(i, 2, n + 1) {
    int j;
    for (j = n; j >= 0; --j){
      if (a[j] % i == 0) {
	a[j] /= i;
	break;
      }
    }
    if (j == -1) {
      assert(! "not found");
    }
  }
  ll sum = 1;
  const ll mod = 1e9;
  REP(i, 0, n) {
    sum *= a[i];
    sum %= mod;
  }
  cout << sum << endl;
}
0