Add MUTC 2017 Team 7

pull/45/head
Kirigaya Kazuto 2017-08-19 17:29:23 +08:00
parent f3c31d48a0
commit 25d4286d34
2 changed files with 75 additions and 0 deletions

View File

@ -0,0 +1,20 @@
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int a;
cin >> a;
if (a % 2 == 1)
cout << (a - 1) / 2 + 2;
else
cout << a / 2 + 1;
cout << endl;
}
}

View File

@ -0,0 +1,55 @@
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
#include <sstream>
#include <bitset>
#include <algorithm>
std::vector<std::size_t> kolakoski(std::size_t size) {
std::vector<std::size_t> vec;
vec.reserve(size);
vec.push_back(1);
vec.push_back(2);
vec.push_back(2);
std::vector<std::size_t>::iterator it = vec.begin() + 2;
while (vec.size() < size) {
if (*it == 1) {
if (vec.back() == 1) {
vec.push_back(2);
}
else { //if (vec.back() == 2) {
vec.push_back(1);
}
}
else { //if (*it == 2) {
if (vec.back() == 1) {
vec.push_back(2);
vec.push_back(2);
}
else { //if (vec.back() == 2) {
vec.push_back(1);
vec.push_back(1);
}
}
++it;
}
return vec;
}
int main() {
int t;
int n[5];
int nmax = 0;
std::cin >> t;
for (int i = 0; i < t; i++) {
std::cin >> n[i];
nmax = std::max(n[i], nmax);
}
std::vector<std::size_t> vec = kolakoski((std::size_t)nmax);
//´Ë´¦Êä³ö
for(int i=0;i<t;i++)
{
std::cout<<vec[n[i]-1]<<std::endl;
}
return 0;
}