题意:给定一个数字,让你构造成一些表达式,最后结果是该数字的概率要大于50%。

析:我们可以把一个数分解是2的多少次幂,然后加起来就好。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#include <sstream>
#define debug() puts("++++");
#define gcd(a, b) __gcd(a, b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std; typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 500 + 10;
const int mod = 1e9 + 7;
const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, 1, 0, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
}
map<int,char> ID;
int f[20]; void init(){
f[1] = 1;
for(int i = 2; i <= 15; ++i) f[i] = 2 * f[i-1];
ID[1] = 'a'; ID[2] = 'b'; ID[4] = 'c';
ID[8] = 'd'; ID[16] = 'e'; ID[32] = 'f';
ID[64] = 'g'; ID[128] = 'h';
printf("%c = ? max ?\n", 9 + 'a');
for(int i = 10; i < 26; ++i) printf("%c = (%c max %c)\n", i+'a', i-1+'a', i-1+'a');
printf("a = (z max z) / z\n");
for(int i = 2; i <= 128; i *= 2)
printf("%c = %c + %c\n",ID[i], ID[i>>1],ID[i>>1]);
} int main(){
freopen("java2016.in","r",stdin);
freopen("java2016.out","w",stdout);
while(scanf("%d", &n) == 1){
if(n == 0){ printf("? /?/ ?\n"); continue; }
init();
bool flag = false;
for(int i = 8; i >= 1; --i){
if(n >= f[i]){
if(flag) printf(" + ");
flag = true;
printf("%c", ID[f[i]]);
n -= f[i];
}
}
printf("\n",'\n');
}
return 0;
}

  

Gym - 101142J Java2016 (构造)的更多相关文章

  1. Codeforces Gym 100531I Instruction 构造

    Problem I. Instruction 题目连接: http://codeforces.com/gym/100531/attachments Description Ingrid is a he ...

  2. Tree Reconstruction Gym - 101911G(构造)

    ---恢复内容开始--- Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given ea ...

  3. UVaLive 6588 && Gym 100299I (贪心+构造)

    题意:给定一个序列,让你经过不超过9的6次方次操作,变成一个有序的,操作只有在一个连续区间,交换前一半和后一半. 析:这是一个构造题,我们可以对第 i 个位置找 i 在哪,假设 i  在pos 位置, ...

  4. TTTTTTTTTTTTTTTTT Gym 100851J Jump 构造

    题意:首先你输入一个数字n(偶数)(n<=1000),电脑则自动生成一个长度为n的01字符串,你每次可以构造出一个长度为n的01字符串,输入给电脑后电脑进行判定,如果你的字符串与电脑的字符串完全 ...

  5. Painting the Fence Gym - 101911E(构造)

    There is a beautiful fence near Monocarp's house. The fence consists of nn planks numbered from left ...

  6. Codeforces Gym 100187K K. Perpetuum Mobile 构造

    K. Perpetuum Mobile Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/pro ...

  7. Codeforces Gym 100342H Problem H. Hard Test 构造题,卡迪杰斯特拉

    Problem H. Hard TestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/at ...

  8. Codeforces Gym 100610 Problem A. Alien Communication Masterclass 构造

    Problem A. Alien Communication Masterclass Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codefo ...

  9. Codeforces Gym 100425H H - Football Bets 构造

    H - Football BetsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...

随机推荐

  1. 关于System.Data.ParameterDirection四个枚举类型所起的作用(转)

    相信大家都知道.net中有四个关于参数传入传出的类型 分别是: System.Data.ParameterDirection.Input System.Data.ParameterDirection. ...

  2. 九度OJ 1055:数组逆置 (基础题)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:7324 解决:3429 题目描述: 输入一个字符串,长度小于等于200,然后将数组逆置输出. 输入: 测试数据有多组,每组输入一个字符串. ...

  3. CSS各种度量单位----px、em、%、rem、vh/vw、vmin/vmax

    本文主要讲下CSS中各类度量单位的意思和区别. 开发中最常用到的css单位是px.em.%.随着css3的出现,带来了更多的度量单位,这些单位为响应式开发,带来很大的好处.各种单位的浏览器兼容性可以去 ...

  4. 常见寄存器以及常见汇编指令,常见爆破指令 good

    CPU的任务就是执行存放在存储器里的指令序列.为此,除要完成算术逻辑操作外,还需要担负CPU和存储器以及I/O之间的数据传送任务.早期的CPU芯片只包括运算器和控制器两大部分.到了近几年,为了使存储器 ...

  5. 【题解】Making The Grade(DP+结论)

    [题解]Making The Grade(DP+结论) VJ:Making the Grade HNOI-D2-T3 原题,禁赛三年. 或许是我做过的最简单的DP题了吧(一遍过是什么东西) 之前做过关 ...

  6. Java基础教程:JDBC编程

    Java基础教程:JDBC编程 1.什么是JDBC JDBC 指 Java 数据库连接,是一种标准Java应用编程接口( JAVA API),用来连接 Java 编程语言和广泛的数据库. JDBC A ...

  7. 校园网络 usaco

    这道题和上一道[最受欢迎的牛]差不多,都是强连通分量的练习题: 第一问实际上就是问缩点后入度为0的点有多少,第二问就是问添加几条边能使缩点后的图变成强连通图: 第一问好做,第二问需要动下脑子,也不难: ...

  8. UVA11077 Find the Permutations —— 置换、第一类斯特林数

    题目链接:https://vjudge.net/problem/UVA-11077 题意: 问n的全排列中多有少个至少需要交换k次才能变成{1,2,3……n}. 题解: 1.根据过程的互逆性,可直接求 ...

  9. 在你的网站中使用 AdSense广告

    下面介绍了如何使用Google的AdSense来为你的网站设置广告.基本内容包括: 创建一个AdSense账号,你必须18岁以上,有一个Google账号以及地址 你的网站必须已经被激活,并且你的网站内 ...

  10. perl 语言学习总结

    .#!/usr/bin/perl -w 内建警告信息,Perl发出警告 .字符串 . 连接符 .重复次数 .字符串与数字之间的自动转换 .; + += *= .= not and or xor .pr ...