結果

問題 No.648  お や す み 
ユーザー cielciel
提出日時 2017-09-18 16:10:27
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 383 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 29,568 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-13 20:43:00
合計ジャッジ時間 2,030 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 84
権限があれば一括ダウンロードができます

ソースコード

diff #

//Rubyだけのテストだと不評を買いそうで.

#include <stdio.h>
__int128_t isqrt(__int128_t n){
  if(n<=0)return 0;
  if(n<4)return 1;
  __int128_t x=0,y=n;
  for(;x!=y&&x+1!=y;)x=y,y=(n/y+y)/2;
  return x;
}
int main(){
  long long n;
  scanf("%lld",&n);
  __int128_t x=(__int128_t)n*8+1,q=isqrt(x);
  if(q*q!=x||q%2==0)puts("NO");
  else printf("YES\n%lld\n",q-1>>1);
}
0