提出 #30653459
ソースコード 拡げる
#include<bits/stdc++.h>
const double pi = acos(-1.0);
using namespace std;
//using namespace __gnu_pbds;
#define endl '\n'
#define sl(n) scanf("%lld",&n)
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int, int>
#define f(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
#define rf(i,a,b) for(ll i = (ll)(a); i > (ll)(b); i--)
#define ms(a,b) memset((a),(b),sizeof(a))
#define abs(x) ((x<0)?(-(x)):(x))
#define MAX 200005
#define inf LLONG_MAX
#define ninf LLONG_MIN
#define MIN INT_MIN
#define yeet return 0;
#define tihs if(fopen("input.txt","r"))freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long MAX2(long long a, long long b) {return (a) > (b) ? (a) : (b);}
inline long long MAX3(long long a, long long b, long long c) {return (a) > (b) ? ((a) > (c) ? (a) : (c)) : ((b) > (c) ? (b) : (c));}
inline long long MIN2(long long a, long long b) {return (a) < (b) ? (a) : (b);}
inline long long MIN3(long long a, long long b, long long c) {return (a) < (b) ? ((a) < (c) ? (a) : (c)) : ((b) < (c) ? (b) : (c));}
//typedef
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;
const int mod = 998244353;
int64_t extGcd(int64_t a, int64_t b, int64_t& x, int64_t& y) {if (!a) {x = 0; y = 1; return b;} int64_t x1, y1; int64_t d = extGcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return d;}
inline ll addmod(ll a, ll b) {a = a % mod + b % mod; if (a > mod)a %= mod; return a;}
inline ll submod(ll a, ll b) {a = a % mod - b % mod; if (a < 0)a += mod; return a;}
inline ll mulmod(ll a, ll b) {return (a % mod * b % mod) % mod;}
int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
inline ll exp(ll a, ll b) {if (a == 0)return 0ll; ll r = 1LL; while (b > 0) {if (b & 1) {r = r * (a % mod); r = (r + mod) % mod;} b /= 2; a = (a % mod) * (a % mod); a = (a + mod) % mod;} return (r + mod) % mod;}
ll gcd(ll a, ll b) {if (b == 0)return a; if (a == 0)return b; return gcd(b, a % b);}
uint32 setbits(ll n) {uint32 count = 0; while (n) {n &= (n - 1); count++;} return count; }
ll f[MAX];
ll iv[MAX];
ll C(ll n, ll r) {
if (n < r)return 0;
ll ans = (f[n] % mod * iv[r] % mod) % mod;
ans = (ans % mod * iv[n - r] % mod) % mod;
return ans % mod;
}
void init() {
f[0] = 1;
iv[0] = 1;
f(i, 1, MAX)f[i] = (i * f[i - 1]) % mod;
iv[MAX - 1] = exp(f[MAX - 1], mod - 2);
for (int i = MAX - 2; i >= 0; --i)iv[i] = (iv[i + 1] * (i + 1)) % mod;
}
////****************************************************************************************************************************************************************************************************************////
ll getVal(ll a, ll b){
return (a*a*a + b*b*b + a*b*a + a*b*b);
}
int main() {
tihs;
fast_io;
int t;
// cin >> t;
t = 1;
while (t--) {
ll n;
cin >> n;
ll num = cbrt(n);
ll ans1=LLONG_MAX;
ll ans2= LLONG_MAX;
ll num2=MIN2(1000000,num+1);
for (ll i = 0; i <= num; i++) {
ll val = getVal(num,i);
if(val>=n){
ans1=val;
break;
}
}
for (ll i = 0; i <= num; i++) {
ll val = getVal(num2,i);
if(val>=n){
ans2=val;
break;
}
}
ll ans3=LLONG_MAX;
ll ans4=LLONG_MAX;
ll num3= cbrt(n/2);
ll num4=MIN2(1000000,num3+4);
for (ll i = 0; i <= num3; i++) {
ll val = getVal(num3,i);
if(val>=n){
ans3=val;
break;
}
}
for (ll i = 0; i <= num3; i++) {
ll val = getVal(num4,i);
if(val>=n){
ans4=val;
break;
}
}
cout<<min({ans1,ans2,ans3,ans4})<<endl;
}
return 0;
}
提出情報
コンパイルエラー
./Main.cpp: In function ‘int main()’:
./Main.cpp:25:47: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
25 | #define tihs if(fopen("input.txt","r"))freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
./Main.cpp:79:2: note: in expansion of macro ‘tihs’
79 | tihs;
| ^~~~
./Main.cpp:25:80: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
25 | #define tihs if(fopen("input.txt","r"))freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
./Main.cpp:79:2: note: in expansion of macro ‘tihs’
79 | tihs;
| ^~~~
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
0 / 400 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
sample_01.txt, sample_02.txt, sample_03.txt |
| All |
sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| sample_01.txt |
AC |
6 ms |
3732 KiB |
| sample_02.txt |
AC |
2 ms |
3608 KiB |
| sample_03.txt |
AC |
5 ms |
3508 KiB |
| test_01.txt |
AC |
2 ms |
3536 KiB |
| test_02.txt |
AC |
2 ms |
3796 KiB |
| test_03.txt |
AC |
2 ms |
3640 KiB |
| test_04.txt |
AC |
3 ms |
3600 KiB |
| test_05.txt |
AC |
2 ms |
3600 KiB |
| test_06.txt |
AC |
2 ms |
3512 KiB |
| test_07.txt |
WA |
4 ms |
3592 KiB |
| test_08.txt |
WA |
5 ms |
3600 KiB |
| test_09.txt |
WA |
3 ms |
3644 KiB |
| test_10.txt |
WA |
7 ms |
3592 KiB |
| test_11.txt |
WA |
5 ms |
3612 KiB |
| test_12.txt |
WA |
7 ms |
3628 KiB |
| test_13.txt |
WA |
5 ms |
3508 KiB |
| test_14.txt |
WA |
4 ms |
3600 KiB |
| test_15.txt |
WA |
4 ms |
3628 KiB |
| test_16.txt |
WA |
10 ms |
3648 KiB |
| test_17.txt |
WA |
6 ms |
3644 KiB |
| test_18.txt |
WA |
6 ms |
3644 KiB |
| test_19.txt |
WA |
7 ms |
3624 KiB |
| test_20.txt |
WA |
4 ms |
3648 KiB |
| test_21.txt |
WA |
4 ms |
3612 KiB |
| test_22.txt |
WA |
8 ms |
3640 KiB |
| test_23.txt |
WA |
4 ms |
3592 KiB |
| test_24.txt |
WA |
5 ms |
3600 KiB |
| test_25.txt |
WA |
6 ms |
3724 KiB |
| test_26.txt |
WA |
4 ms |
3736 KiB |
| test_27.txt |
AC |
8 ms |
3596 KiB |