結果

問題 No.1918 Simple Math ?
ユーザー Duy Nguyễn TườngDuy Nguyễn Tường
提出日時 2023-02-14 01:04:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,160 bytes
コンパイル時間 2,096 ms
コンパイル使用メモリ 199,860 KB
実行使用メモリ 18,492 KB
最終ジャッジ日時 2023-09-23 14:21:31
合計ジャッジ時間 9,785 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
10,732 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 5 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 4 ms
4,380 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 57 ms
10,732 KB
testcase_07 WA -
testcase_08 AC 33 ms
8,544 KB
testcase_09 AC 20 ms
5,200 KB
testcase_10 WA -
testcase_11 AC 5 ms
4,380 KB
testcase_12 AC 59 ms
8,472 KB
testcase_13 AC 38 ms
9,484 KB
testcase_14 AC 24 ms
7,164 KB
testcase_15 AC 12 ms
4,380 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 222 ms
9,768 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

// #cheatkhitacontre #khionhatoicheat
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long /*fuck int*/
using namespace std;
int mod = 1000000007;
int Sqrt(int x) {
    int ret = 0;
    for (int i = (1ll<<31); i >= 1; i>>=1) if ((ret+i)*(ret+i)<=x) ret += i;
    return ret;
}
int mul(int a, int b) {
    return (a*b)%mod;
}
int binpow(int a, int b) {
    int ret = 1;
    while (b) {
        if (b&1) ret = mul(ret,a);
        a = mul(a,a);
        b >>= 1;
    }
    return ret;
}
int Sum(int a, int b) {
    return (a+b+mod)%mod;
}
int sub(int a, int b) {
    return (a-b+mod)%mod;
}
int Div(int a, int b) {
    return mul(a,binpow(b,mod-2));
}
void solve() {
    int n, a, m, ss = 0, s = 0;
    cin >> a >> n;
    m = Sqrt(a*n);
    vector<int> dp(a+1,0);
    for (int i = 1; i <= a; i++) dp[i] = Sum(dp[i],(i*i-1)%a+1);
    for (int i = 1; i <= a; i++) s = Sum(s,dp[i]);
    for (int i = 1; i <= m%a; i++) ss = Sum(ss,dp[i]);
    cout << sub(mul(m,n),Div(sub(Div(mul(mul(m,m+1),2*m+1),6ll),Sum(mul(s,m/a),ss)),a)) << "\n";
}
signed main() {
	IOS;
	int TEST=1;
	cin >> TEST;
	while (TEST--) solve();
}
0