結果
問題 |
No.376 立方体のN等分 (2)
|
ユーザー |
![]() |
提出日時 | 2018-04-18 16:22:01 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 459 ms / 5,000 ms |
コード長 | 484 bytes |
コンパイル時間 | 891 ms |
コンパイル使用メモリ | 23,680 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-27 04:30:18 |
合計ジャッジ時間 | 4,612 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 38 |
コンパイルメッセージ
main.c: In function ‘run’: main.c:26:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 26 | scanf("%lld",&n); | ^~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h> #include<math.h> #define MIN(a,b) ((a)<(b)?(a):(b)) typedef long long int int64; int64 calc(int64 n){ int64 min=n-1; int i,j; for(i=1;(int64)i*i*i<=n;i++){ if(n%i!=0) continue; int64 t=n/i; for(j=sqrt(t)+1;j>=i;j--){ if(t%j==0){ min=MIN(i-1+j-1+(t/j)-1,min); break; } } } return min; } void run(void){ int64 n; scanf("%lld",&n); printf("%lld %lld\n",calc(n),n-1); return; } int main(void){ run(); return 0; }