結果

問題 No.1281 Cigarette Distribution
ユーザー 沙耶花沙耶花
提出日時 2020-11-06 22:29:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 836 bytes
コンパイル時間 2,067 ms
コンパイル使用メモリ 201,768 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-29 19:07:46
合計ジャッジ時間 5,233 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace atcoder;
using mint = modint1000000007;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 10000000000000000



int main(){
	
	int N,M;
	cin>>N>>M;
	
	for(int i=1;i<=M;i++){
		if(i==1){
			cout<<N<<endl;
			continue;
		}
		if(i==2){
			long long x = 0,y = 0;
			rep(i,N){
				if(x>y)swap(x,y);
				x += 2;
				if(x>y)swap(x,y);
				x--;
			}
			
			cout<<mint(x*y).val()<<endl;
			
			continue;
		}
		
		int a = (N-3)/(i-2);
		int b = a+1;
		long long ok = 0,ng = i-2+1;
		while(ng-ok>1){
			long long mid = (ok+ng)/2;
			if(mid*b+((long long)i-2-mid)*a > (N-3))ng = mid;
			else ok = mid;
		}
		
		mint ans = mint(a).pow(i-2-ok);
		ans *= mint(b).pow(ok);
		ans *= 2;
		
		cout<<ans.val()<<endl;
		
	}
	
    return 0;
}
0