我是靠谱客的博主 执着导师,最近开发中收集的这篇文章主要介绍BC15hdoj5082&&hdoj5083&&hdoj5084LoveInstructionHeHe,觉得挺不错的,现在分享给大家,希望可以做个参考。
概述
Love
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 801 Accepted Submission(s): 484
Problem Description
There is a Love country with many couples of Darby and Joan in it. In order to commemorate their love, they will do some thing special when giving name to their offspring.
When a couple want to give name to their offspring, they will firstly get their first names, and list the one of the male before the one of the female. Then insert the string “small” between their first names. Thus a new name is generated. For example, the first name of male is Green, while the first name of the female is Blue, then the name of their offspring is Green small Blue.
You are expected to write a program when given the name of a couple, output the name of their offsping.
When a couple want to give name to their offspring, they will firstly get their first names, and list the one of the male before the one of the female. Then insert the string “small” between their first names. Thus a new name is generated. For example, the first name of male is Green, while the first name of the female is Blue, then the name of their offspring is Green small Blue.
You are expected to write a program when given the name of a couple, output the name of their offsping.
Input
Multi test cases (about 10), every case contains two lines.
The first line lists the name of the male.
The second line lists the name of the female.
In each line the format of the name is [given name]_[first name].
Please process to the end of file.
[Technical Specification]
3 ≤ the length of the name ≤ 20
[given name] only contains alphabet characters and should not be empty, as well as [first name].
The first line lists the name of the male.
The second line lists the name of the female.
In each line the format of the name is [given name]_[first name].
Please process to the end of file.
[Technical Specification]
3 ≤ the length of the name ≤ 20
[given name] only contains alphabet characters and should not be empty, as well as [first name].
Output
For each case, output their offspring’s name in a single line in the format [first name of male]_small_[first name of female].
Sample Input
Jim_Green Alan_Blue
Sample Output
Green_small_Blue
Source
BestCoder Round #15
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<list>
#include<queue>
#include<vector>
using namespace std;
const int maxn=110;
char stra[maxn];
char strb[maxn];
int main()
{
while(scanf("%s%s",stra,strb)!=EOF){
bool sign=false;
for(int i=0;i<strlen(stra);++i){
if(sign)printf("%c",stra[i]);
if(stra[i]=='_')sign=true;
}
printf("_small");
for(int i=0;i<strlen(strb);++i){
if(strb[i]=='_')sign=false;
if(!sign)printf("%c",strb[i]);
}
printf("n");
}
return 0;
}
Instruction
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 953 Accepted Submission(s): 227
Problem Description
Nowadays, Jim Green has produced a kind of computer called JG. In his computer, the instruction is represented by binary code. However when we code in this computer, we use some mnemonic symbols. For example, ADD R1, R2 means to add the number in register R1 and R2, then store the result to R1. But this instruction cannot be execute directly by computer, before this instruction is executed, it must be changed to binary code which can be executed by computer. Each instruction corresponds to a 16-bit binary code. The higher 6 bits indicates the operation code, the middle 5 bits indicates the destination operator, and the lower 5 bits indicates the source operator. You can see Form 1 for more details.
In JG system there are 6 instructions which are listed in Form 2.
Operation code is generated according to Form 3.
Destination operator code and source operator code is the register code of the register which is related to.
There are 31 registers in total. Their names are R1,R2,R3…,R30,R31. The register code of Ri is the last 5 bits of the number of i in the binary system. For eaxample the register code of R1 is 00001, the register code of R2 is 00010, the register code of R7 is 00111, the register code of R10 is 01010, the register code of R31 is 11111.
So we can transfer an instruction into a 16-bit binary code easyly. For example, if we want to transfer the instruction ADD R1,R2, we know the operation is ADD whose operation code is 000001, destination operator code is 00001 which is the register code of R1, and source operator code is 00010 which is the register code of R2. So we joint them to get the 16-bit binary code which is 0000010000100010.
However for the instruction SET Ra, there is no source register, so we fill the lower 5 bits with five 0s. For example, the 16-bit binary code of SET R10 is 0001100101000000
You are expected to write a program to transfer an instruction into a 16-bit binary code or vice-versa.
15 operation code(6 bits)109destination operator code(5 bits)54source operator code(5 bits)0Form 1
In JG system there are 6 instructions which are listed in Form 2.
instructionADD Ra,RbSUB Ra,RbDIV Ra,RbMUL Ra,RbMOVE Ra,RbSET RafunctionAdd the number in register Ra and Rb, then store the result to Ra.Subtract the number in register Ra to Rb, then store the result to Ra.Divide the number in register Ra by Rb, then store the result to Ra.Mulplicate the number in register Ra and Rb, then store the result to Ra.Move the number in register Rb to Ra.Set 0 to Ra.Form 2
Operation code is generated according to Form 3.
OperationADDSUBDIVMULMOVESETOperation code000001000010000011000100000101000110Form 3
Destination operator code and source operator code is the register code of the register which is related to.
There are 31 registers in total. Their names are R1,R2,R3…,R30,R31. The register code of Ri is the last 5 bits of the number of i in the binary system. For eaxample the register code of R1 is 00001, the register code of R2 is 00010, the register code of R7 is 00111, the register code of R10 is 01010, the register code of R31 is 11111.
So we can transfer an instruction into a 16-bit binary code easyly. For example, if we want to transfer the instruction ADD R1,R2, we know the operation is ADD whose operation code is 000001, destination operator code is 00001 which is the register code of R1, and source operator code is 00010 which is the register code of R2. So we joint them to get the 16-bit binary code which is 0000010000100010.
However for the instruction SET Ra, there is no source register, so we fill the lower 5 bits with five 0s. For example, the 16-bit binary code of SET R10 is 0001100101000000
You are expected to write a program to transfer an instruction into a 16-bit binary code or vice-versa.
Input
Multi test cases (about 50000), every case contains two lines.
First line contains a type sign, ‘0’ or ‘1’.
‘1’ means you should transfer an instruction into a 16-bit binary code;
‘0’ means you should transfer a 16-bit binary code into an instruction.
For the second line.
If the type sign is ‘1’, an instruction will appear in the standard form which will be given in technical specification;
Otherwise, a 16-bit binary code will appear instead.
Please process to the end of file.
[Technical Specification]
The standard form of instructions is
ADD Ra,Rb
SUB Ra,Rb
DIV Ra,Rb
MUL Ra,Rb
MOVE Ra,Rb
SET Ra
which are also listed in the Form 2.
1≤a,b≤31
There is exactly one space after operation, and exactly one comma between Ra and Rb other than the instruction SET Ra. No other character will appear in the instruction.
First line contains a type sign, ‘0’ or ‘1’.
‘1’ means you should transfer an instruction into a 16-bit binary code;
‘0’ means you should transfer a 16-bit binary code into an instruction.
For the second line.
If the type sign is ‘1’, an instruction will appear in the standard form which will be given in technical specification;
Otherwise, a 16-bit binary code will appear instead.
Please process to the end of file.
[Technical Specification]
The standard form of instructions is
ADD Ra,Rb
SUB Ra,Rb
DIV Ra,Rb
MUL Ra,Rb
MOVE Ra,Rb
SET Ra
which are also listed in the Form 2.
1≤a,b≤31
There is exactly one space after operation, and exactly one comma between Ra and Rb other than the instruction SET Ra. No other character will appear in the instruction.
Output
For type ‘0’,if the 16-bit binary code cannot be transferred into a instruction according to the description output “Error!” (without quote), otherwise transfer the 16-bit binary code into instruction and output the instruction in the standard form in a single line.
For type ‘1’, transfer the instruction into 16-bit binary code and output it in a single line.
For type ‘1’, transfer the instruction into 16-bit binary code and output it in a single line.
Sample Input
1 ADD R1,R2 0 0000010000100010 0 1111111111111111
Sample Output
0000010000100010 ADD R1,R2 Error!
Source
BestCoder Round #15
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<list>
#include<queue>
#include<vector>
using namespace std;
const int maxn=10010;
char str[110];
char stra[110];
char strb[110];
char strc[110];
int main()
{
int oper,i,j;
while(scanf("%d",&oper)!=EOF){
if(oper==1){
scanf("%s",stra);
if(strcmp(stra,"ADD")==0||strcmp(stra,"SUB")==0||strcmp(stra,"DIV")==0||strcmp(stra,"MUL")==0||strcmp(stra,"MOVE")==0){
scanf("%s",strb);
if(strcmp(stra,"ADD")==0)
printf("000001");
else if(strcmp(stra,"SUB")==0)
printf("000010");
else if(strcmp(stra,"DIV")==0)
printf("000011");
else if(strcmp(stra,"MUL")==0)
printf("000100");
else if(strcmp(stra,"MOVE")==0)
printf("000101");
int a=0;
for(i=0;i<strlen(strb);++i){
if(strb[i]>='0'&&strb[i]<='9'){
a=a*10+strb[i]-'0';
}
if(strb[i]==',')break;
}
for(int bit=4;bit>=0;--bit){
if(a&(1<<bit))printf("1");
else printf("0");
}
int b=0;
for(j=i+1;j<strlen(strb);++j){
if(strb[j]>='0'&&strb[j]<='9'){
b=b*10+strb[j]-'0';
}
}
for(i=4;i>=0;--i){
if(b&(1<<i))printf("1");
else printf("0");
}
printf("n");
}
else {
scanf("%s",strb);
printf("000110");
int a=0;
for(i=0;i<strlen(strb);++i){
if(strb[i]>='0'&&strb[i]<='9'){
a=a*10+strb[i]-'0';
}
}
for(i=4;i>=0;--i){
if(a&(1<<i))printf("1");
else printf("0");
}
printf("00000n");
}
}
else {
scanf("%s",str);
if(strlen(str)!=16){
printf("Error!n");
continue;
}
int a=0;
for(i=0;i<6;++i){
stra[a++]=str[i];
}stra[a]=0;
int x=0,y=0;
for(i=6,a=0;i<11;++i){
strb[a++]=str[i];
x=x+(str[i]-'0')*(1<<(5-a));
}strb[a]=0;
for(i=11,a=0;i<16;++i){
strc[a++]=str[i];
y=y+(str[i]-'0')*(1<<(5-a));
}strc[a]=0;
if(strcmp(stra,"000001")==0){
if(x>=1&&x<=31&&y>=1&&y<=31){
printf("ADD R%d,R%dn",x,y);
}
else printf("Error!n");
}
else if(strcmp(stra,"000010")==0){
if(x>=1&&x<=31&&y>=1&&y<=31){
printf("SUB R%d,R%dn",x,y);
}
else printf("Error!n");
}
else if(strcmp(stra,"000011")==0){
if(x>=1&&x<=31&&y>=1&&y<=31){
printf("DIV R%d,R%dn",x,y);
}
else printf("Error!n");
}
else if(strcmp(stra,"000100")==0){
if(x>=1&&x<=31&&y>=1&&y<=31){
printf("MUL R%d,R%dn",x,y);
}
else printf("Error!n");
}
else if(strcmp(stra,"000101")==0){
if(x>=1&&x<=31&&y>=1&&y<=31){
printf("MOVE R%d,R%dn",x,y);
}
else printf("Error!n");
}
else if(strcmp(stra,"000110")==0){
if(x>=1&&x<=31&&y==0){
printf("SET R%dn",x);
}
else printf("Error!n");
}
else printf("Error!n");
}
}
return 0;
}
HeHe
Time Limit: 5000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 331 Accepted Submission(s): 132
Problem Description
M=⎛⎝⎜⎜⎜⎜⎜⎜⎜⎜⎜tn−1tn−2tn−3⋮t1t0tntn−1tn−2⋮t2t1tn+1tntn−1⋮t3t2⋯⋯⋯⋱⋯⋯t2∗n−3t2∗n−4t2∗n−5⋮tn−1tn−2t2∗n−2t2∗n−3t2∗n−4⋮tntn−1⎞⎠⎟⎟⎟⎟⎟⎟⎟⎟⎟
You are expected to write a program to point out some elements of M∗M .
Input
Multi test cases (about 100), every case occupies two lines.
The first line contains an integer n.
Then second line contain 2*n-1 integers t0,t1,t2,t3,…,t2∗n−4,t2∗n−3,t2∗n−2 separated by exact one space.
The third line contains an integer m, indicates the number of query.
Next m lines will give queries
r0r1r2⋮rm−1c0c1c2⋮cm−1
For r0,c0 the program will query the element of M∗M which locates in the rth0 row, cth0 column. For ri,ci(0<i<m) , assume that the answer of i−1th query is ANS, the program will query the element of M∗M which locates in ((ri+ANS)%n)th row, ((ci+ANS)%n)th column.
Please process to the end of file.
[Technical Specification]
1≤n≤1000
0≤ti≤100
0≤ri,ci≤n−1
1≤m≤100000
The first line contains an integer n.
Then second line contain 2*n-1 integers t0,t1,t2,t3,…,t2∗n−4,t2∗n−3,t2∗n−2 separated by exact one space.
The third line contains an integer m, indicates the number of query.
Next m lines will give queries
r0r1r2⋮rm−1c0c1c2⋮cm−1
For r0,c0 the program will query the element of M∗M which locates in the rth0 row, cth0 column. For ri,ci(0<i<m) , assume that the answer of i−1th query is ANS, the program will query the element of M∗M which locates in ((ri+ANS)%n)th row, ((ci+ANS)%n)th column.
Please process to the end of file.
[Technical Specification]
1≤n≤1000
0≤ti≤100
0≤ri,ci≤n−1
1≤m≤100000
Output
For each case,output the sum of the answer of each query.
Sample Input
3 1 2 3 1 2 2 0 0 1 2 4 10 5 7 2 10 5 7 3 1 2 3 0 2 1 2 1 2 3 4 0 0 0 1 1 0 1 1
Sample Output
23 348 22Hint$quad text{For the first case }M = begin{pmatrix} 3 & 1 & 2\ 2 & 3 & 1\ 1 & 2 & 3 end{pmatrix}$ $text{For the second case }M = begin{pmatrix} 2 & 10 & 5 & 7\ 7 & 2 & 10 & 5\ 5 & 7 & 2 & 10\ 10 & 5 & 7 & 2 end{pmatrix}$
Source
BestCoder Round #15
标程讲的哪种方法还不会只会这个较为简单的方法时间复杂度较高数据强的话可能超时
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<list>
#include<queue>
#include<vector>
using namespace std;
const int maxn=1010;
long long num[maxn<<1];
int main()
{
int n,m,i,j,k;
while(scanf("%d",&n)!=EOF){
for(i=0;i<=2*n-2;++i){
scanf("%lld",&num[i]);
}
scanf("%d",&m);
int ans=0,x,y;
long long sum=0;
while(m--){
scanf("%d%d",&x,&y);
x=(x+ans)%n;y=(y+ans)%n;
ans=0;
for(i=0;i<n;++i){
ans=ans+num[n-1-x+i]*num[n-1+y-i];
}
sum+=ans;
}
printf("%lldn",sum);
}
return 0;
}
最后
以上就是执着导师为你收集整理的BC15hdoj5082&&hdoj5083&&hdoj5084LoveInstructionHeHe的全部内容,希望文章能够帮你解决BC15hdoj5082&&hdoj5083&&hdoj5084LoveInstructionHeHe所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复