mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Add MUTC 2017 Team 7
This commit is contained in:
parent
f3c31d48a0
commit
25d4286d34
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user