結果
| 問題 | 
                            No.1862 Copy and Paste
                             | 
                    
| コンテスト | |
| ユーザー | 
                             vjudge1
                         | 
                    
| 提出日時 | 2024-11-13 09:50:27 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 740 bytes | 
| コンパイル時間 | 2,224 ms | 
| コンパイル使用メモリ | 197,964 KB | 
| 最終ジャッジ日時 | 2025-02-25 04:02:21 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 4 | 
| other | AC * 1 WA * 26 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         scanf("%lld %lld %lld", &n, &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            
            ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=1e7+5;
ll n, x, y, ans=4e18;
int main() {
//	freopen("dice.in", "r", stdin);
//	freopen("dice.out","w",stdout);
	scanf("%lld %lld %lld", &n, &x, &y);
	if(n==1) {
		puts("0");
		return 0; 
	}
	if((__int128)n*y<=(ll)(1e18))
		ans=min(ans, x+(n-1)*y);
	ll sq=sqrt(n), t=sq+sq-2;
	if(sq*sq<n) t++;
	if(sq*(sq+1)<n) t++;
	if((__int128)t*y<=(ll)(1e18))
		ans=min(ans, x+x+t*y);
	for(ll i=3; i<=__lg(n)+1; i++) {
		priority_queue<ll> q; 
		ll now=1, b=0;
		for(int j=1; j<=i; j++) q.push(-2), now=now*2;
		while(now<n) {
			ll u=-q.top(); q.pop();
			now/=u; now*=u+1; 
			q.push(-(u+1));
			b++;
		}
		ans=min(ans, i*x+(i+b)*y);
	}
	printf("%lld\n", ans);
	return 0;
}
            
            
            
        
            
vjudge1