https://www.acmicpc.net/problem/15596 : ์ ์ N๊ฐ์ ํฉ
#include <iostream>
#include <vector>
#include <iterator>
using namespace std;
long long sum(std::vector<int> &a){
long long sum = 0;
vector<int>::iterator ptr;
for (ptr = a.begin(); ptr != a.end(); ++ptr)
sum += *ptr;
return sum;
}
https://www.acmicpc.net/problem/4673 : ์ ํ ๋๋ฒ
#include <iostream>
using namespace std;
bool self[10001];
int d(int a){
int num = a;
while (true){
if (a == 0) break;
num += a % 10;
a /= 10;
}
return num;
}
int main(void){
for(int i = 1; i < 10001; i++){
int n = d(i);
if(n < 10001) self[n] = true;
}
for(int i = 1; i < 10001; i++)
if(!self[i])
printf("%d\n", i);
return 0;
}
https://www.acmicpc.net/problem/1065 : ํ์
#include <iostream>
using namespace std;
bool is_han(int a){
if(a < 100) return true;
else{
int a1 = a / 100;
int a2 = a / 10 % 10;
int a3 = a % 10;
if(a1 - a2 == a2 - a3) return true;
}
return false;
}
int main(void){
int n, count = 0;
cin >> n;
for(int i = 1; i <= n; i++){
if(is_han(i)) count += 1;
}
cout << count << endl;
}
ํ์ด์ฌ์ด ์ต๊ณ ์ธ๊ฑด ๋ง๋๋ฐ ํ์คํ c++์ด ์ด๋ง์ด๋งํ๊ฒ ๋น ๋ฅด๋ค,,
์๋ฐ๋ ํ์ด์ฌ๋ ์๊ฐ์ด ๊ฝค ๊ฑธ๋ฆฌ๋๋ฐ c++์ ๊ณ์ 0ms๊ฐ ๋จ๋ค.. ๊ต์ฅํด ์์ฒญ๋