提出 #64516823


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    
    ll N;
    cin >> N;

    ll ans=0;

    ll lo=0, hi=1e9+100;
    while(lo+1<hi)
    {
        ll mid=lo+hi>>1;
        if(mid*mid<=N) lo=mid;
        else hi=mid;
    }
    ans+=lo;

    lo=0, hi=1e9;
    while(lo+1<hi)
    {
        ll mid=lo+hi>>1;
        if(2*mid*mid<=N) lo=mid;
        else hi=mid;
    }
    ans+=lo;

    lo=0, hi=1e9;
    while(lo+1<hi)
    {
        ll mid=lo+hi>>1;
        if((2*mid-1)*(2*mid-1)<=N) lo=mid;
        else hi=mid;
    }
    ans-=lo;


    cout << ans << "\n";
}

提出情報

提出日時
問題 C - 2^a b^2
ユーザ arnold518
言語 C++ 20 (gcc 12.2)
得点 350
コード長 752 Byte
結果 AC
実行時間 1 ms
メモリ 3644 KiB

コンパイルエラー

Main.cpp: In function ‘int main()’:
Main.cpp:22:18: warning: suggest parentheses around ‘+’ inside ‘>>’ [-Wparentheses]
   22 |         ll mid=lo+hi>>1;
      |                ~~^~~
Main.cpp:31:18: warning: suggest parentheses around ‘+’ inside ‘>>’ [-Wparentheses]
   31 |         ll mid=lo+hi>>1;
      |                ~~^~~
Main.cpp:40:18: warning: suggest parentheses around ‘+’ inside ‘>>’ [-Wparentheses]
   40 |         ll mid=lo+hi>>1;
      |                ~~^~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 350 / 350
結果
AC × 3
AC × 29
セット名 テストケース
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt
ケース名 結果 実行時間 メモリ
example_00.txt AC 1 ms 3488 KiB
example_01.txt AC 1 ms 3484 KiB
example_02.txt AC 1 ms 3508 KiB
hand_00.txt AC 1 ms 3500 KiB
hand_01.txt AC 1 ms 3364 KiB
hand_02.txt AC 1 ms 3456 KiB
hand_03.txt AC 1 ms 3484 KiB
hand_04.txt AC 1 ms 3512 KiB
hand_05.txt AC 1 ms 3568 KiB
hand_06.txt AC 1 ms 3476 KiB
hand_07.txt AC 1 ms 3472 KiB
hand_08.txt AC 1 ms 3484 KiB
hand_09.txt AC 1 ms 3556 KiB
hand_10.txt AC 1 ms 3476 KiB
random_00.txt AC 1 ms 3568 KiB
random_01.txt AC 1 ms 3364 KiB
random_02.txt AC 1 ms 3512 KiB
random_03.txt AC 1 ms 3500 KiB
random_04.txt AC 1 ms 3428 KiB
random_05.txt AC 1 ms 3364 KiB
random_06.txt AC 1 ms 3472 KiB
random_07.txt AC 1 ms 3360 KiB
random_08.txt AC 1 ms 3484 KiB
random_09.txt AC 1 ms 3472 KiB
random_10.txt AC 1 ms 3440 KiB
random_11.txt AC 1 ms 3364 KiB
random_12.txt AC 1 ms 3644 KiB
random_13.txt AC 1 ms 3440 KiB
random_14.txt AC 1 ms 3560 KiB