結果

問題 No.681 Fractal Gravity Glue
ユーザー kotatsugamekotatsugame
提出日時 2018-04-27 23:56:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 786 bytes
コンパイル時間 1,028 ms
コンパイル使用メモリ 65,816 KB
実行使用メモリ 8,752 KB
最終ジャッジ日時 2023-09-10 07:03:18
合計ジャッジ時間 4,363 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,752 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 3 ms
4,384 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:44:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   44 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
const long long mod=1e9+7;
long long count(int i,int d)
{
	long long ans=0;
	for(long long j=1;j<=i;j++)
	{
		ans=(d+ans*(d+1)%mod)%mod;
	}
	return ans;
}
long long sum(int i,int d)
{
	long long ans=0;
	for(long long j=1;j<=i;j++)
	{
		ans=(j*d%mod+ans*(d+1)%mod)%mod;
	}
	return ans;
}
long long sumcount(int i,int d,int n)
{
	long long s=count(i-1,d),t=sum(i-1,d);
	long long now=0;
	for(;;)
	{
		if(n<s)
		{
			return (now+sumcount(i-1,d,n))%mod;
		}
		else if(n==s)
		{
			return (now+t)%mod;
		}
		else if(n==s+1)
		{
			return (now+t+i)%mod;
		}
		now=(now+t+i)%mod;
		n-=s+1;
	}
}
main()
{
	long long n,b,d;cin>>n>>b>>d;
	for(int i=1;;i++)
	{
		if(count(i,d)>n)
		{
			cout<<(sum(b,d)+mod-sumcount(i,d,n))%mod<<endl;
			return 0;
		}
	}
}
0