Submission #40351


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd( ll x, ll y );
ll lcm( ll x, ll y );
bool IsPrime( ll n );
int main()
{
stack<int> st;
int data;
string operation;
cin >> operation;
while ( operation != "exit" ) {
if ( operation == "push" ) {
scanf("%d", &data );
st.push(data);
} else if ( operation == "top" ) {
printf("%d\n", st.top() );
} else if ( operation == "pop" ) {
st.pop();
}
cin >> operation;
}
return 0;
}
ll gcd( ll x, ll y )
{
if ( y == 0 ) return x;
return gcd( y, x % y );
}
ll lcm( ll x, ll y )
{
return x / gcd( x, y ) * y;
}
bool IsPrime( ll n )
{
if ( n < 2 ) return false;
else if ( n == 2 ) return true;
else if ( n % 2 == 0 ) return false;
for ( ll i = 3; i <= sqrt( n ); i += 2 ) {
if ( n % i == 0 ) return false;
}
return true;
}

ステータス

項目 データ
問題 0600 - プログラミング入門:Stack
ユーザー名 ei1711
投稿日時 2018-07-31 15:27:09
言語 C++11
状態 Accepted
得点 1
ソースコード長 1009 Byte
最大実行時間 681 ms
最大メモリ使用量 19760 KB

セット

セット 得点 Cases
1 ALL 1 / 1 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
Input01 AC 50 ms 608 KB
1
Input02 AC 20 ms 580 KB
1
Input03 AC 24 ms 424 KB
1
Input04 AC 44 ms 524 KB
1
Input05 AC 41 ms 620 KB
1
Input06 AC 61 ms 1092 KB
1
Input07 AC 84 ms 2132 KB
1
Input08 AC 228 ms 4888 KB
1
Input09 AC 493 ms 11020 KB
1
Input10 AC 681 ms 19760 KB
1