More actions
imported>novaman No edit summary |
(Repair batch-0004 pages from live compare) |
||
| (4 intermediate revisions by one other user not shown) | |||
| Line 1: | Line 1: | ||
== 상태 == | |||
{| class="wikitable" style="width:100%;" | |||
|- | |||
| Problem | |||
| 1953 | |||
| User | |||
| finchpark | |||
|- | |||
| Memory | |||
| 260K | |||
| Time | |||
| 16MS | |||
|- | |||
| Language | |||
| C++ | |||
| Result | |||
| Accepted | |||
|} | |||
== 소스 == | == 소스 == | ||
=== Presentation Version === | === Presentation Error Version === | ||
#include <iostream> | #include <iostream> | ||
| Line 20: | Line 38: | ||
{ | { | ||
cin >> getPatternNum; | cin >> getPatternNum; | ||
scenario | scenario[i] = getPatternNum; | ||
} | } | ||
| Line 26: | Line 44: | ||
for(int i = 0; i < getLineNum; i++) | for(int i = 0; i < getLineNum; i++) | ||
cout << "Scenario #" << i + 1 << ":" << endl << trumpet(scenario | cout << "Scenario #" << i + 1 << ":" << endl << trumpet(scenario[i]) << endl << endl; | ||
free(scenario); | free(scenario); | ||
| Line 73: | Line 91: | ||
{ | { | ||
cin >> getPatternNum; | cin >> getPatternNum; | ||
scenario | scenario[i] = getPatternNum; | ||
cout << "Scenario #" << i + 1 << ":" << endl << trumpet(scenario | cout << "Scenario #" << i + 1 << ":" << endl << trumpet(scenario[i]) << endl << endl; | ||
} | } | ||
| Line 106: | Line 124: | ||
* 아... 입력 받고 시나리오 바로 출력하는 방식이었네요.. 전 처음에 입력 다 받고 나서 출력하는 거였는데.. 영어가 문제네요 -_-a | * 아... 입력 받고 시나리오 바로 출력하는 방식이었네요.. 전 처음에 입력 다 받고 나서 출력하는 거였는데.. 영어가 문제네요 -_-a | ||
* 재귀함수는 느려서 시간 초과되네요 | |||
Latest revision as of 00:37, 27 March 2026
상태
| Problem | 1953 | User | finchpark |
| Memory | 260K | Time | 16MS |
| Language | C++ | Result | Accepted |
소스
Presentation Error Version
#include <iostream>
using namespace std;
int trumpet(int num);
int main()
{
int getLineNum = 0;
int getPatternNum = 0;
int *scenario;
cin >> getLineNum;
scenario = (int*)malloc(sizeof(int) * getLineNum);
for(int i = 0; i < getLineNum; i++)
{
cin >> getPatternNum;
scenario[i] = getPatternNum;
}
cout << endl;
for(int i = 0; i < getLineNum; i++)
cout << "Scenario #" << i + 1 << ":" << endl << trumpet(scenario[i]) << endl << endl;
free(scenario);
return 0;
}
int trumpet(int num)
{
int temp = 0;
int result_1 = 2;
int result_2 = 3;
if(num == 1)
return result_1;
else if(num == 2)
return result_2;
else{
for(int i = 2; i < num; i++) {
temp = result_1 + result_2;
result_1 = result_2;
result_2 = temp;
}
return result_2;
}
}
Accepted Version
#include <iostream>
using namespace std;
int trumpet(int num);
int main()
{
int getLineNum = 0;
int getPatternNum = 0;
int *scenario;
cin >> getLineNum;
scenario = (int*)malloc(sizeof(int) * getLineNum);
for(int i = 0; i < getLineNum; i++)
{
cin >> getPatternNum;
scenario[i] = getPatternNum;
cout << "Scenario #" << i + 1 << ":" << endl << trumpet(scenario[i]) << endl << endl;
}
free(scenario);
return 0;
}
int trumpet(int num)
{
int temp = 0;
int result_1 = 2;
int result_2 = 3;
if(num == 1)
return result_1;
else if(num == 2)
return result_2;
else{
for(int i = 2; i < num; i++) {
temp = result_1 + result_2;
result_1 = result_2;
result_2 = temp;
}
return result_2;
}
}
잡담
- 근데 Presentation Error가 나는데 -_-;; Terminate the output for the scenario with a blank line 이 부분을 내가 잘못 이해하고 있어서인거 같기도 하네염 -ㅅ-;; 에잇,, Visual Studio에서 돌리면 돌아는 갑니다. -ㅅ-
- 아... 입력 받고 시나리오 바로 출력하는 방식이었네요.. 전 처음에 입력 다 받고 나서 출력하는 거였는데.. 영어가 문제네요 -_-a
- 재귀함수는 느려서 시간 초과되네요