回答ケース
総スコア:169ランキング:NaN 3を
Tlの:T2 9:100 T3:60
各被験者分析
トピック1:
推定結果:20実績スコア:9つの検査:2:30 -午前3時00分、午前4時00分- 5時
スタートサイケT1は、式の美しいが、比較的少ない使用を開始しました。
暴力の最初のヒットの後に他の質問をお読みください。
トピック2:
100回の検査::推計結果:100実際のパフォーマンス3時-午前3時20分
テンプレートのタイトルフェルマーの定理小さな。
接触がある前に、迅速に行います。
トピック3:
60回の検査::推計結果:100実際のパフォーマンス3:30 - 3時50
以前は同様のブロックが割り切れる行わ。
これに基づき、我々はいくつかの計算を追加しました。
失われたバーストLONGLONG 40分の計算以来。
- レッスン:データが及ぶことに注意してください!データが及ぶ場合は、より大きなモジュロ時刻を覚えています。
分析タイトル
T1:
18点:
暴力列挙S、暴力決意。
100:
テーブルの形而上学を再生して式を起動することができます。
T2:
フェルマーの小定理のシンプルなアプリケーションです。
インデックスが大きい場合には、迅速な指数演算を直接実行することはできません。
モジュラスが素数であるので、フェルマーの小定理がある:\(A ^ {P-1} \当量1 \ PMOD P \。)
次に、\(^ {B ^ C } \当量A ^ {B ^ C \ %(P - 1)} \ PMOD P \)
そして、高速電力のためのインデックスの塩基数は引き継ぐことができます。
複雑\(O(\ログK) \)
T3:
割り切れるブロックシンプルなアプリケーション。
いずれかのための\(D \) 、(\ 1 \ N-SIM) \ ここで発生要因の回数(\ \ {N-dfrac} {D} \) 。
これは、に見出すことができる(\ dfrac {n}は{\ D} \) で\(D \)デクリメントインクリメントされます。
答えるために、この因子の寄与である\(\ lfloor \ {N-dfrac} {D} \ rfloor \タイムズD ^ 2 \) 。
以下のための(1 \ SIM N \)\正方形と式:(\ \ {。。。N-dfrac(N + 1)(2N + 1)6} {} \) 。
注\(F(I)= \ dfrac {I(i + 1)の(I + 1)} {6} \)
ための\(\ lfloor \ dfrac {N }、{D} \ rfloor \) 単調減少、多くの値の連続範囲があります。
発生数のためのものである(\ dfrac {n}は{\ I} \) 因子\(I \ J SIM \) 、
合計寄与:\((F(J) - F(1-I))\タイムズ。 \ lfloor \ dfrac {n}は{ I} \ rfloor \)
明らかに、上記の式は、分割を遮断することによって解決することができます。
各ブロックの\(\ lfloor \ dfrac {N } {I} \ rfloor \) 寄与がある間隔、- \((F(j)は F(I-1))\回\ lfloor \ dfrac {N} {I} \ rfloor \)
いつでもノートの取り方
コードの実装
T1:
診察室コード
//
/*
By:Luckyblock
*/
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <algorithm>
#define ll long long
const int MARX = 110 + 10;
const int mod = 1e9 + 7;
//=============================================================
int N, K, Ans, f[MARX] = {1};
//=============================================================
inline int read()
{
int f = 1, w = 0; char ch = getchar();
for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
for(; isdigit(ch); ch = getchar()) w = (w << 3) + (w << 1) + (ch ^ '0');
return f * w;
}
//=============================================================
int main()
{
freopen("cute.in", "r", stdin);
freopen("cute.out", "w", stdout);
N = read(), K = read();
for(int i = 1; i <= N; i ++) f[i] = f[i - 1] * K;
for(int s = 1; s < f[N]; s ++)
{
int flag = 1;
for(int i = 1; i < N - 1; i ++)
if(s % f[i] * f[N - i] <= s)
{flag = 0; break;}
Ans += flag, Ans %= mod;
}
printf("%d", Ans);
return 0;
}
正解
#include <iostream>
#include <algorithm>
using namespace std;
long long const P=1000000007,M=100000;
int m;
long long n,k,g[M],f[M];
bool isprime(long long x)
{
if (x==1) return false;
for (long long i=2;i*i<=x;i++)
if (x % i==0) return false;
return true;
}
long long comp(long long b,long long c,long long m)
{
long long ans=1;
long long l=b;
long long j=1;
while (j<=c)
{
if ((j & c)>0) ans=(ans*l) % m;
j*=2;
l=(l*l) % m;
}
return ans;
}
int main()
{
freopen("cute.in","r",stdin);
freopen("cute.out","w",stdout);
cin>>n>>k;
for (long long i=1;i*i<=n;i++)
if (n % i==0)
{
g[++m]=i;
if (i*i<n) g[++m]=n/i;
}
sort(g+1,g+m+1);
f[1]=k;
for (int i=2;i<=m;i++)
{
f[i]=comp(k,g[i],P);
for (int j=1;j<=i-1;j++)
if (g[i] % g[j]==0) f[i]=(f[i]+P-f[j]) % P;
}
printf("%lld\n",f[m]*comp(n,P-2,P) % P);
}
T2:
検査コード(正の解)
//
/*
By:Luckyblock
*/
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <algorithm>
#define ll long long
//=============================================================
ll a, b, c, p;
//=============================================================
inline ll read()
{
ll f = 1, w = 0; char ch = getchar();
for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
for(; isdigit(ch); ch = getchar()) w = (w << 3) + (w << 1) + (ch ^ '0');
return f * w;
}
ll qpow(ll x, ll y, ll mod)
{
ll ret = 1;
for(; y; x = x * x % mod, y >>= 1)
if(y & 1) ret = ret *x % mod;
return ret;
}
//=============================================================
int main()
{
freopen("number.in", "r", stdin);
freopen("number.out", "w", stdout);
a = read(), b = read(), c = read(), p = read();
ll x = qpow(b, c, p - 1);
printf("%lld", qpow(a, x, p));
return 0;
}
T3:
検査コード(正の解)
//
/*
By:Luckyblock
*/
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <algorithm>
#define ll long long
//=============================================================
ll N, Mod, ans, inv;
//=============================================================
inline ll read()
{
ll f = 1, w = 0; char ch = getchar();
for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
for(; isdigit(ch); ch = getchar()) w = (w << 3) + (w << 1) + (ch ^ '0');
return f * w;
}
ll qpow(ll x, ll y, ll mod)
{
ll ret = 1;
for(; y; x = x * x % mod, y >>= 1)
if(y & 1) ret = ret * x % mod;
return ret;
}
ll SquareSum(ll L, ll R)
{
ll suml = L * (L + 1) % Mod * (2 * L % Mod + 1) % Mod * inv % Mod;
ll sumr = R * (R + 1) % Mod * (2 * R % Mod + 1) % Mod * inv % Mod;
return (sumr - suml + Mod) % Mod;
}
//=============================================================
int main()
{
N = read(), Mod = read();
inv = qpow(6, Mod - 2, Mod);
for(ll i = 1, j; i <= N; i = j + 1)
{
j = N / (N / i);
ans = (ans + SquareSum((i - 1) % Mod , j % Mod) * (N / i) % Mod) % Mod;
}
printf("%lld\n", ans);
system("pause");
return 0;
}