題目連結 http://zerojudge.tw/ShowProblem?problemid=a053。
直接套用題目給的公式即可。
程式碼:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() { | |
int n; | |
int s; | |
while(cin >> n) | |
{ | |
if(n <= 10) | |
{ | |
s = 6 * n; | |
} | |
else if(n <= 20) | |
{ | |
s = 60 + 2 * (n-10); | |
} | |
else if(n <= 40) | |
{ | |
s = 80 + n - 20; | |
} | |
else | |
{ | |
s = 100; | |
} | |
cout << s << endl; | |
} | |
return 0; | |
} |
沒有留言:
張貼留言