結果

問題 No.2368 I love a square root of 2
ユーザー maksimmaksim
提出日時 2023-07-01 00:46:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 924 ms / 2,000 ms
コード長 1,015 bytes
コンパイル時間 2,630 ms
コンパイル使用メモリ 172,100 KB
実行使用メモリ 70,380 KB
最終ジャッジ日時 2023-09-21 18:20:09
合計ジャッジ時間 8,554 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 924 ms
69,060 KB
testcase_03 AC 4 ms
4,376 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 723 ms
69,744 KB
testcase_14 AC 733 ms
70,280 KB
testcase_15 AC 827 ms
69,488 KB
testcase_16 AC 525 ms
36,528 KB
testcase_17 AC 9 ms
4,380 KB
testcase_18 AC 21 ms
5,064 KB
testcase_19 AC 22 ms
5,056 KB
testcase_20 AC 19 ms
5,088 KB
testcase_21 AC 906 ms
70,380 KB
testcase_22 AC 895 ms
69,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define int long long
bool cmp(pair<int,int> u,pair<int,int> v)
{
    if(u.first==v.first && u.second==v.second) return false;
    if(u.first>=v.first && u.second>=v.second) return false;
    if(u.first<=v.first && u.second<=v.second) return true;
    if(u.first>=v.first)
    {
        return (u.first-v.first)*(u.first-v.first)<2*(u.second-v.second)*(u.second-v.second);
    }
    else
    {
        return (u.first-v.first)*(u.first-v.first)>2*(u.second-v.second)*(u.second-v.second);
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;--n;
    int k=sqrt(n*2*sqrt(2.0));
    k-=10;
    int n1=n;
    vector<pair<int,int> > v;
    for(int a=0;a<=k+20;++a)
    {
        int b0=max(0LL,((int) ((k-a)/sqrt(2.0))));
        n1-=b0;
        for(int j=b0;j<=b0+20;++j)
        {
            v.push_back({a,j});
        }
    }
    sort(v.begin(),v.end(),cmp);
    cout<<v[n1].first<<' '<<v[n1].second;
    return 0;
}
0