ACM ICPC 2016–2017, NEERC, Northern Subregional Contest Problem J. Java2016
Posted destr
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 ?
b=a max a
c=b max b
d=c max c
e=d max d
f=e max e
g=f max f
h=g max g
i=h max h
j=i max i
k=j max j
l=k max k
m=l/l
";
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+="
";
ans+="n*n";
for(int i=nn*nn+1;i<=n;i++)
{
ans+="+m";
}
ans+="
";
cout<<str<<ans;
return 0;
}
以上是关于ACM ICPC 2016–2017, NEERC, Northern Subregional Contest Problem J. Java2016的主要内容,如果未能解决你的问题,请参考以下文章
2016-2017 ACM-ICPC, NEERC, Northern Subregional Contest Problem I. Integral Polygons
2016-2017 ACM-ICPC, NEERC, Moscow Subregional Contest Problem L. Lazy Coordinator
2017-2018 ACM-ICPC, NEERC, Moscow Subregional Contest
2017-2018 ACM-ICPC Northern Eurasia (Northeastern European Regional) Contest (NEERC 17)
2017-2018 ACM-ICPC Northern Eurasia (Northeastern European Regional) Contest (NEERC 17)题解+补题
2017-2018 ACM-ICPC, NEERC, Northern Subregional ContestG - Grand Test