Aaronson】的更多相关文章

Aaronson 题意: 给个中文链接:戳戳戳 题解: 这题一看给的公式就是二进制,之后马上就能想到当m大于等于二进制的位数时,输出n的二进制的1的个数就好了.之后就是m小于二进制的位数时,只要加上2的(总位数-m)次方就好了,当且仅当这一位是1的时候成立. 代码: #include <cmath> #include <cstdio> #include <iostream> #include <algorithm> using namespace std;…
题目链接: Aaronson Time Limit: 4000/2000 MS (Java/Others)     Memory Limit: 131072/131072 K (Java/Others) Problem Description Recently, Peter saw the equation x0+2x1+4x2+...+2mxm=n. He wants to find a solution (x0,x1,x2,...,xm) in such a manner that ∑i=0…
Aaronson Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 425    Accepted Submission(s): 255 Problem Description Recently, Peter saw the equation x0+2x1+4x2+...+2mxm=n. He wants to find a solut…
T :  1 n m:  10  2 题解:20 * 0  +  21* 1  +  22* 2 = 10 输出:3  <--  0+1+2=3 AC 代码: #include<stdio.h> #include<algorithm> using namespace std; int main(void) { int T,n,m; int val=0; while(scanf("%d",&T)!=EOF) { while(T--) { scanf(…
Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 231    Accepted Submission(s): 149 Problem Description Recently, Peter saw the equation x0+2x1+4x2+...+2mxm=n. He wants to find a solution (x0,x…
题目: Recently, Peter saw the equation x0+2x1+4x2+...+2mxm=nx0+2x1+4x2+...+2mxm=n. He wants to find a solution (x0,x1,x2,...,xm)(x0,x1,x2,...,xm) in such a manner that ∑i=0mxi∑i=0mxi is minimum and every xixi (0≤i≤m0≤i≤m) is non-negative. Input There a…
题目大意 vjudge链接 给你一个n,m,求解满足等式x0+2x1+4x2+...+2mxm=n的x0~xm的最小和(xi为非负整数) 数据范围 0≤n,m≤109 思路 n和m都在int范围内,所以当i≥30时,xi必为0 求最小和用贪心解决 代码 1 #include <cstdio> 2 #include <algorithm> 3 using namespace std; 4 int n,m; 5 6 int main(){ 7 int T; 8 scanf("…
A题 Aaronson http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=718&pid=1001 感觉一开始写的这个不好,太冗余了. #include <cstdio> int main() { int n,m; int t; while(~scanf("%d",&t)) { while(t--) { scanf("%d%d",&n,&…
A题:Aaronson 静下心来观察就会发现1.如果m大于等于n的位数,那么n直接写成二进制形式就是最优解形式2.如果m小于n的位数,那么贪心地使得高位尽可能地多消掉n的值,因为高位少写一个数就意味着低位要写更多位来弥补抵消3.在第二种情况下,枚举2^m也不会超int,因为(n<le9)最多有30位,且m小于n的位数,m就不会很大 #include <bits/stdc++.h> using namespace std; ; inline int cacu(int x) { ; whil…
0x01 从判定问题到形式语言 这篇讲知识证明的wiki([1]): https://en.wikipedia.org/wiki/Proof_of_knowledge 里面有一句话: Let x be a language element of language L in NP 这篇讲NPC的文章([2]) http://www.cs.princeton.edu/courses/archive/spr11/cos423/Lectures/NP-completeness.pdf 里面提到Decis…