QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#315242#8167. Yet Another Simple Math Problemucup-team1430#WA 9ms3632kbC++20791b2024-01-27 09:22:062024-01-27 09:22:07

Judging History

你现在查看的是最新测评结果

  • [2024-01-27 09:22:07]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:3632kb
  • [2024-01-27 09:22:06]
  • 提交

answer

#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define int long long
#define pb push_back
#define endl '\n'
#define sws cin.tie(0)->sync_with_stdio(false);
#define int long long

using namespace std;

const int N = 1e5+5;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;

void solve(){
    ll n; cin >> n;
    if(n == 1){
        cout << 0 << endl;
        return;
    }
    ll x = sqrt(n)+10;
    while(x*x+1 > n){
        x--;
    }

    ll ans = (x-1)*(x-1);
    ans += (n-x*x)*2;
    if(x*x+x == n) ans--;
    cout << ans << endl;
}

main() {
    #ifndef LOCAL
    sws
    #endif

    int t = 1; cin >> t;
    while(t--){
        solve();
    }
    
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3632kb

input:

3
6
1
101

output:

4
0
83

result:

ok 3 tokens

Test #2:

score: -100
Wrong Answer
time: 9ms
memory: 3612kb

input:

100000
73697
33010
17110
47753
12905
6499
31281
81851
77880
81156
73047
17517
37475
77689
74726
65569
63357
6041
61519
88597
1857
65620
55973
56676
28171
88517
65432
20685
41538
92074
39812
86863
83657
14646
76700
47385
10860
39669
52855
22282
53629
751
99085
6000
22003
31593
99242
61157
17982
91695...

output:

73412
32898
17061
47547
12816
6439
31235
81335
77362
81089
72655
17347
37316
77539
74378
65091
63212
6000
61039
88392
1780
65193
55779
56233
28120
88232
65330
20636
41462
91734
39626
86703
83216
14410
76673
47248
10697
39340
52812
22066
53436
720
98947
5918
21807
31504
98630
60812
17741
91583
6972
4...

result:

wrong answer 2nd words differ - expected: '32761', found: '32898'