結果

問題 No.2989 Fibonacci Prize
ユーザー 沙耶花沙耶花
提出日時 2024-12-14 00:31:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 994 bytes
コンパイル時間 4,466 ms
コンパイル使用メモリ 269,836 KB
実行使用メモリ 27,792 KB
最終ジャッジ日時 2024-12-14 00:32:01
合計ジャッジ時間 15,238 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,816 KB
testcase_02 AC 47 ms
8,400 KB
testcase_03 AC 2 ms
6,816 KB
testcase_04 AC 2 ms
6,820 KB
testcase_05 AC 2 ms
6,820 KB
testcase_06 AC 2 ms
6,816 KB
testcase_07 AC 2 ms
6,820 KB
testcase_08 AC 2 ms
6,820 KB
testcase_09 AC 2 ms
6,816 KB
testcase_10 AC 1 ms
6,816 KB
testcase_11 AC 2 ms
6,816 KB
testcase_12 AC 2 ms
6,816 KB
testcase_13 WA -
testcase_14 AC 2 ms
6,816 KB
testcase_15 AC 2 ms
6,816 KB
testcase_16 AC 2 ms
6,816 KB
testcase_17 AC 1 ms
6,820 KB
testcase_18 AC 2 ms
6,820 KB
testcase_19 AC 2 ms
6,816 KB
testcase_20 AC 2 ms
6,816 KB
testcase_21 AC 2 ms
6,820 KB
testcase_22 AC 2 ms
6,820 KB
testcase_23 AC 2 ms
6,816 KB
testcase_24 AC 63 ms
8,636 KB
testcase_25 AC 63 ms
11,280 KB
testcase_26 AC 2 ms
6,820 KB
testcase_27 AC 2 ms
6,820 KB
testcase_28 AC 21 ms
6,816 KB
testcase_29 AC 20 ms
6,816 KB
testcase_30 AC 2 ms
6,820 KB
testcase_31 AC 6 ms
6,816 KB
testcase_32 AC 2 ms
6,820 KB
testcase_33 AC 69 ms
10,568 KB
testcase_34 AC 6 ms
6,816 KB
testcase_35 AC 2 ms
6,820 KB
testcase_36 AC 68 ms
9,932 KB
testcase_37 AC 71 ms
8,480 KB
testcase_38 AC 5 ms
6,816 KB
testcase_39 AC 3 ms
6,820 KB
testcase_40 AC 7 ms
6,820 KB
testcase_41 AC 16 ms
6,816 KB
testcase_42 AC 50 ms
9,120 KB
testcase_43 AC 552 ms
27,744 KB
testcase_44 AC 494 ms
27,772 KB
testcase_45 AC 676 ms
27,792 KB
testcase_46 AC 336 ms
22,440 KB
testcase_47 AC 258 ms
23,200 KB
testcase_48 AC 282 ms
22,476 KB
testcase_49 AC 489 ms
22,560 KB
testcase_50 AC 413 ms
21,528 KB
testcase_51 AC 302 ms
22,220 KB
testcase_52 AC 386 ms
22,064 KB
testcase_53 AC 416 ms
21,972 KB
testcase_54 AC 388 ms
22,684 KB
testcase_55 AC 375 ms
19,392 KB
testcase_56 AC 282 ms
19,384 KB
testcase_57 AC 282 ms
19,368 KB
testcase_58 AC 354 ms
22,000 KB
testcase_59 AC 387 ms
21,616 KB
testcase_60 AC 343 ms
21,572 KB
testcase_61 AC 321 ms
19,108 KB
testcase_62 AC 284 ms
18,920 KB
testcase_63 AC 311 ms
18,992 KB
testcase_64 AC 2 ms
6,820 KB
testcase_65 AC 2 ms
6,820 KB
testcase_66 AC 2 ms
6,816 KB
testcase_67 AC 2 ms
6,816 KB
testcase_68 WA -
testcase_69 AC 2 ms
6,816 KB
testcase_70 AC 2 ms
6,816 KB
testcase_71 AC 1 ms
6,816 KB
testcase_72 WA -
testcase_73 AC 2 ms
6,820 KB
testcase_74 AC 2 ms
6,816 KB
testcase_75 AC 2 ms
6,816 KB
testcase_76 WA -
testcase_77 AC 1 ms
6,816 KB
testcase_78 AC 2 ms
6,820 KB
testcase_79 AC 2 ms
6,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint1000000007;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 2000000001
#define Inf64 4000000000000000001LL


int main(){
	
	long long N,M;
	cin>>N>>M;
	if(M==1){
		if(1%N==0){
			cout<<2<<endl;
		}
		return 0;
	}
	vector<pair<long long,long long>> t(1,{1%N,1%N});
	
	while(true){
		long long x = t.back().second;
		long long y = x + t.back().first;
		y %= N;
		if(x==1%N&&y==1%N)break;
		t.push_back({x,y});
	}
	map<long long,long long> mp;
	rep(i,t.size()){
		mp[t[i].first] += M / t.size();
	}
	rep(i,M % t.size()){
		mp[t[i].first] ++;
	}
	mp[t[0].first] --;
	long long ans = 0;
	for(auto a:mp){
		long long v = a.second;
		ans += v * (v-1) / 2;
	}
	{
		long long tt = M - 2;
		if(t[tt%t.size()].first == 0)ans++;
	}
	{
		long long tt = M - 1;
		if(t[tt%t.size()].first == 0){
			ans ++;
			if(M>=3)ans++;
		}
	}
	cout<<ans<<endl;
	
	return 0;
}
0