Submission #927743
Source Code Expand
// eddy1021
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long ll;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<LD,LD> Pt;
typedef tuple<int,int,int> tiii;
typedef tuple<LL,LL,LL> tlll;
#define mod9 1000000009ll
#define mod7 1000000007ll
#define INF 1023456789ll
#define INF16 10000000000000000ll
#define FI first
#define SE second
#define X FI
#define Y SE
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...)
#endif
inline LL getint(){
LL _x=0,_tmp=1; char _tc=getchar();
while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
if( _tc == '-' ) _tc=getchar() , _tmp = -1;
while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
_x += _y;
return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
_x -= _y;
return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
_x *= _y;
return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
if( _x == 0 ) return 1LL;
LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
if( _x & 1 ) _ret = mul( _ret , _a , _mod );
return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
if( _x == 0 ) return 0LL;
LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
if( _x & 1 ) _ret = add( _ret , _a , _mod );
return _ret;
}
inline bool equal( D _x , D _y ){
return _x > _y - eps && _x < _y + eps;
}
int __ = 1 , _cs;
/*********default*********/
#define N 1021
void build(){
}
LL n , t[ N ] , a[ N ];
void init(){
scanf( "%lld" , &n );
for( int i = 0 ; i < n ; i ++ )
scanf( "%lld%lld" , &t[ i ] , &a[ i ] );
}
void solve(){
LL tt = t[ 0 ] , aa = a[ 0 ];
for( int i = 1 ; i < n ; i ++ ){
LL gg = max( tt / t[ i ] , aa / a[ i ] );
while( gg * t[ i ] < tt ||
gg * a[ i ] < aa ) gg ++;
tt = gg * t[ i ];
aa = gg * a[ i ];
}
printf( "%lld\n" , tt + aa );
}
int main(){
build();
//__ = getint();
while( __ -- ){
init();
solve();
}
}
Submission Info
Compile Error
./Main.cpp: In function ‘void init()’:
./Main.cpp:74:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf( "%lld" , &n );
^
./Main.cpp:76:44: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf( "%lld%lld" , &t[ i ] , &a[ i ] );
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
300 / 300 |
Status |
|
|
Set Name |
Test Cases |
Sample |
0_000.txt, 0_001.txt, 0_002.txt |
All |
0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt |
Case Name |
Status |
Exec Time |
Memory |
0_000.txt |
AC |
2 ms |
256 KB |
0_001.txt |
AC |
2 ms |
256 KB |
0_002.txt |
AC |
3 ms |
256 KB |
1_003.txt |
AC |
2 ms |
256 KB |
1_004.txt |
AC |
3 ms |
256 KB |
1_005.txt |
AC |
3 ms |
256 KB |
1_006.txt |
AC |
3 ms |
256 KB |
1_007.txt |
AC |
3 ms |
256 KB |
1_008.txt |
AC |
2 ms |
256 KB |
1_009.txt |
AC |
3 ms |
256 KB |
1_010.txt |
AC |
2 ms |
256 KB |
1_011.txt |
AC |
3 ms |
256 KB |
1_012.txt |
AC |
2 ms |
256 KB |
1_013.txt |
AC |
3 ms |
256 KB |
1_014.txt |
AC |
3 ms |
256 KB |