Code: Select all
AC
Moderator: Board moderators
Code: Select all
AC
Code: Select all
2
11
13 2 89 377 8 3 233 34 144 21 1
OH, LAME SAINT!AAAAAA
15
34 21 13 144 1597 3 987 610 8 5 89 2 377 2584 1
O, DRACONIAN DEVIL!
Code: Select all
#include <cmath>
#include <climits>
#include <queue>
#include <vector>
#include <map>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <sstream> // istringstream buffer(myString);
#include <stack>
#include <algorithm>
#include <cstring>
#include <cassert>
using namespace std;
#define bit(x,i) (x&(1<<i)) //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x) // big bug here if "-x" is not surrounded by "()"
#define IN(i,l,r) (l<i&&i<r) //the next for are for checking bound
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<r)
#define F(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FF(i,L,R) for (int i = L; i > R; i--)
#define FFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a) //next three are handy ways to get ints, it's also force you to use '&' sign
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define wez(n) int (n); scanf("%d",&(n)) //handy if the input is right after the definition of a variable
#define wez2(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define wez3(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define TESTS wez(testow)while(testow--) //for multilple cases problems
#define whileZ int T; getI(T); while(T--) // the same as above
#define getS(x) scanf("%s", x) //get a char* string
#define clr(a,x) memset(a,x,sizeof(a)) //set elements of array to some value
#define char2Int(c) (c-'0')
#define lastEle(vec) vec[vec.size()-1]
#define SZ(x) ((int)((x).size()))
#define REMAX(a,b) (a)=max((a),(b)) // set a to the maximum of a and b
#define REMIN(a,b) (a)=min((a),(b));
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) // traverse an STL data structure
#define ALL(c) (c).begin(),(c).end() //handy for function like "sort()"
#define PRESENT(c,x) ((c).find(x) != (c).end())
#define CPRESENT(c,x) (find(ALL(c),x) != (c).end())
#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF 1001001001
#define PI 3.1415926535897932384626
#define size 4000
using namespace std;
int ary[100+10];
map<int, int>M;
void pre()
{
M.clear();
ary[1] = 1;
M[ary[1]]=1;
ary[2] = 2;
M[ary[2]]=2;
for (int i = 3; i <46; i++)
{
ary[i] = ary[i - 1] + ary[i - 2];
M[ary[i]] = i;
//printf("%d\n",ary[17]);
//printf("%d\n",M[ary[i]]);
}
//for (int i = 1; i <46; i++)
//printf("%d %d\n",ary[17],M[ary[17]]);
}
int main()
{
pre();
//vector<int>numbers;
string ss;
int numbers[1010];
char result[1010];
//freopen("in.txt","r",stdin );
//freopen("out.txt","w+",stdout );
int test,fib,no;
scanf("%d", &test);
while ( test-- )
{
scanf("%d", &fib);
for(int i=0; i<fib; i++)
{
scanf("%d",&numbers[i] );
//numbers.push_back;
}
getchar();
getline(cin,ss);
//cout<<ss<<endl;
memset(result,' ',sizeof(result));
int k=0;
int cn=0;
int max=0;
for(int i=0; i<ss.length(); i++)
{
if ( ss[i] >= 'A' && ss[i] <= 'Z' )
{
int y = M[ numbers[k] ];
result[y-1] = ss[i];
if( (y-1) > max )
max = y-1;
k++;
}
}
if( max == 0 )
{
sort( numbers,numbers+fib );
int d=numbers[0];
max=M[d];
//printf("%d\n",max);
}
//result[]=;
result[max+1]='\0';
cout<<result;
cout<<endl;
}
return 0;
}
Code: Select all
5
5
8 5 3 2 1
ABCDEFG
4
1 5 2 3
ABCDE
4
1 3 2 5
A a B b C c D d E e
1
13
ABCD
1
3
ABC
Code: Select all
EDCBA
ACDB
ACBD
A
A
Code: Select all
erased
Code: Select all
char s2[l2 + 1];
Code: Select all
s2[l2] = '\0';
Code: Select all
#include<iostream>
#include<cstdio>
#include<string>
#include<string.h>
#include<utility>
#include<algorithm>
#include<vector>
#include<cstring>
#include<ctype.h>
#include<cstdlib>
#include<math.h>
using namespace std;
int main() {
string katas;
char ans[101];
int series[101];
int left, right, target, index, mid, k;
vector<int> fibos;
fibos.push_back(1);
fibos.push_back(2);
unsigned int a, b, c = 2, fib = 0;
while (c <= 100) {
if (fib >= 2147438647) break;
fib = fibos[c - 2] + fibos[c - 1];
fibos.push_back(fib);
c++;
}
scanf("%d", &a);
for (int i = 0; i < a; i++)
{
memset(ans, 32, sizeof(ans));
scanf("%d", &b);
for (int j = 0; j < b; j++)
{
scanf("%d", &series[j]);
}
katas = "";
getline(cin, katas);
getline(cin, katas);
k = 0;
for (int j = 0;j < b;j++) {
left = 0;
right = fibos.size();
target = series[j];
while (left <= right) {
mid = (right + left) / 2;
if (fibos[mid] == target) {
while (!isalpha(katas.at(k)) || !isupper(katas.at(k)))k++;
ans[mid] = katas.at(k);
k++;
break;
}
else if (fibos[mid] > target) {
right = mid - 1;
}
else if (fibos[mid] < target) {
left = mid + 1;
}
}
}
for (int j = 0; j < b; j++)
{
if (ans[j] == ' ')b++;
printf("%c", ans[j]);
}
if (i != a - 1) {
printf("\n");
}
}
return 0;
}