A - 圆桌问题: HDU - 4841
#include<iostream>
#include<vector>
#include<stdio.h>
#include<string>
using namespace std;
int main()
{
vector<int> table;
int n,m;
while(scanf("%d%d",&n,&m)!=EOF)
{
table.clear();
for(int i=0;i<2*n;++i)
{
table.push_back(i);
}
int pos = 0;
for(int i=0;i<n;++i)
{
pos = (pos+m-1)%table.size();
table.erase(table.begin()+pos);
}
int j=0;
for(int i=0;i<2*n;++i)
{
if(!(i%50)&&i)cout<<endl;
if(j<table.size()&&i==table[j])
{
++j;
cout<<"G";
}
else
{
cout<<"B";
}
}
cout<<endl<<endl;
}
return 0;
}
C - 简单计算器 HDU - 1237
好自闭啊,找了半天还是WA了,完全不知道WA在哪里了Orz,先存一个档:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream>
#include<stack>
#include<stdio.h>
#include<string>
#include<map>
#define CHECK_NUM(ch) ('0'<=ch&&ch<='9')
#define CHECK_OP(ch) ('+'==ch ||'-'==ch||'*'==ch||'/'==ch ||' '==ch)
using namespace std;
map<char,int>dir;
stack<double> num;
stack<char> op;
stack<double> newnum;
stack<char> newop;
double OPT(double one,double two,char temp)
{
// printf("%f",two);
double three=0;
switch(temp)
{
case '+':three = two + one;break;
case '-':three = two - one;break;
case '*':three = two * one;break;
case '/':three = two / one;break;
}
// printf("%c %lf = %lf
",temp,one,three);
return three;
}
void initi()
{
while(!num.empty())num.pop();
while(!op.empty())op.pop();
while(!newop.empty())newop.pop();
while(!newnum.empty())newnum.pop();
}
void STACK(char ch)
{
// cout<<ch<<endl;
if(!op.empty()&&num.size()>1)
{
char temp=op.top();
// cout<<"当前栈顶:"<<temp<<",当前扫描:"<<ch<<endl;
if(dir[temp]>=dir[ch])
{
op.pop();
double one=num.top();num.pop();
double two=num.top();num.pop();
num.push(OPT(one,two,temp));
// cout<<"入栈num:"<<num.top()<<endl;
}
}
op.push(ch);
}
int main()
{
char ch='