結果

問題 No.1281 Cigarette Distribution
ユーザー 沙耶花
提出日時 2020-11-06 22:29:24
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 836 bytes
コンパイル時間 2,023 ms
コンパイル使用メモリ 196,084 KB
最終ジャッジ日時 2025-01-15 20:58:49
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 4 WA * 19
権限があれば一括ダウンロードができます

ソースコード

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