ACM ICPC 2016–2017, NEERC, Northern Subregional Contest Problem J. Java2016
题目来源:http://codeforces.com/group/aUVPeyEnI2/contest/229510
时间限制:2s
空间限制:256MB
题目大意:
给定一个数字c
用 "max" "min" "+" "-" "" "/"对随机数 "?" 进行处理,使最后式子得到c的概率超过1/2
(所有数字均在0~255之间,"+" "-" ""结果对256取模,"/" 向下取整)
样例:
解法:先使用多个"max"使得到的值趋近于255,然后相除得到1,然后相加到sqrt(c),再加到c
代码:
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define pi acos(-1.0)
#define mem0(a) memset(a,0,sizeof(a))
#define memf(b) memset(b,false,sizeof(b))
#define ll long long
#define eps 1e-10
#define inf 1e17
#define maxn 101010
string str="a=? max ?\nb=a max a\nc=b max b\nd=c max c\ne=d max d\nf=e max e\ng=f max f\nh=g max g\ni=h max h\nj=i max i\nk=j max j\nl=k max k\nm=l/l\n";
int main()
{
freopen("java2016.in","r",stdin);
freopen("java2016.out","w",stdout);
int n,i,j;
cin>>n;
if(n==0)
{
puts("?/?/?");
return 0;
}
int nn=sqrt(n);
string ans="n=m";
for(int i=1;i<=nn-1;i++)
{
ans+="+m";
}
ans+="\n";
ans+="n*n";
for(int i=nn*nn+1;i<=n;i++)
{
ans+="+m";
}
ans+="\n";
cout<<str<<ans;
return 0;
}