113 - Power of Cryptography

import java.math.BigInteger;
import java.util.Scanner; public class Main { public static void main(String[] args) {
// TODO Auto-generated method stub
BigInteger num1, num2;
int n;
int kc = 1000000000;
int l, r, mid, t;
Scanner in = new Scanner(System.in);
while (in.hasNext())
{
n = in.nextInt();
num1 = in.nextBigInteger();
l = 0;
r = kc;
while (true)//二分
{
mid = (l + r) >> 1;
num2 = BigInteger.valueOf(mid);
num2 = num2.pow(n);
t = num2.compareTo(num1);
if (t == 0)
{
System.out.println(mid);
break;
}
else
if (t > 0)
r = mid - 1;
else
l = mid + 1;
}
}
} }

10161 Ant on a Chessboard

#include <iostream>
#include <fstream>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath> using namespace std; int main()
{
long long int n, nt, mid, x, y;
while (cin>>n, n)
{
x = y = nt = ceil(sqrt(n));
mid = (nt * nt + (nt - ) * (nt - ) + ) >> ;/**< long long 防止mid超了 */
//cout<<mid<<endl;
if (n != mid)
{
if (n > mid)
{
if (nt & )/**< n为奇数, 从左到右,再下 在左边*/
{
x = x - n + mid;
}
else/**< 从下到上再到左 在下边*/
{
y = y - n + mid;
}
}
else
{
if (nt & )/**< n为奇数, 从左到右,再下 在下边*/
{
y = y + n - mid;
}
else/**< 从下到上再到左 在左边*/
{
x = x + n - mid;
}
}
}
cout<<x<<' '<<y<<endl;
}
return ;
}

253 - Cube painting

#include <iostream>
#include <fstream>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath> using namespace std;
char s[], ts[];
int a[][] =/**< 枚举,总共24种情况,
在枚举中可以发现(1, 6)(2, 5)(3, 4)两两一组,
当其中一组换位置时,另外两组中必须只有一组需要换位置,
或者但两组互换时,其中一组也要换位置 */
{
, , , , , ,
, , , , , ,
, , , , , ,
, , , , , ,
, , , , , ,
, , , , , ,
, , , , , ,
, , , , , ,
, , , , , ,
, , , , , ,
, , , , , ,
, , , , , ,
, , , , , ,
, , , , , ,
, , , , , ,
, , , , , ,
, , , , , ,
, , , , , ,
, , , , , ,
, , , , , ,
, , , , , ,
, , , , , ,
, , , , , ,
, , , , ,
};
bool fun()
{
int i, j;
for (i = ; i < ; i++)
{
for (j = ; j < ; j++)
if (s[a[][j]] != ts[a[i][j]])
break;
if (j == )
return true;
}
return false;
}
int main()
{
int i = ;
while (cin>>s[i++])
{
for (; i < ; i++)
cin>>s[i];
s[i] = '\0';
for (i = ; i < ; i++)
cin>>ts[i];
ts[i] = '\0';
cout<<(fun() ? "TRUE" : "FALSE")<<endl;
if (cin.get() == EOF)
break;
i = ;
}
return ;
}

10025 - The ? 1 ? 2 ? ... ? n = k problem

 /**< 思路:
先记f(n) = (n*(n+1))/2;
现将k转换为正数,求k对应于f(n)的最小上界n,
从n开始,
第一步:如果f(n) - k这个数是偶数,则输出n,否则
n++,继续第一步。 i = f(n) - k>=0肯定成立,
如果i为要使得f(n) = ?1?2?...?n = k;
就要在f(n)中将i的一半为正,一半为负即可。所以i必定为偶数。
*/
#include <iostream>
#include <cmath>
using namespace std; int main()
{
int n, k, i;
cin>>n;
while (n--)
{
cin>>k;
if (k == )//为0输出3
{
i = ;
}
else
{
if (k < )
{
k = -k;
}
i = sqrt(k * );
if (((i * (i + )) / - k) < )
i++;
while (((i * (i + )) / - k) & )
{
i++;
}
} cout<<i<<endl;
if (n)
{
cout<<endl;
}
}
return ;
}

591 - Box of Bricks

#include <iostream>
#include <cmath>
using namespace std;
int arr[];
int main()
{
int n, avg, s, t = ;
while (cin>>n, n)
{
s = avg = ;
for (int i = ; i < n; i++)
{
cin>>arr[i];
avg += arr[i];
}
avg /= n;
for (int i = ; i < n; i++)
{
s += abs(arr[i] - avg);
}
cout<<"Set #"<<t++<<endl;
cout<<"The minimum number of moves is "<<s / <<"."<<endl<<endl;
}
return ;
}

621 - Secret Research

//这样就过了
#include <iostream>
#include <string>
using namespace std;
string s;
int main()
{
int n, len;
cin>>n;
char r;
while(n--)
{
cin>>s;
len = s.size() - ;
if (len <= )
{
r = '+';
}
else
if (s[len] == '' && s[len - ] == '')
{
r = '-';
}
else
if (s[len] == '' && s[] == '')
{
r = '*';
}
else
{
r = '?';
}
cout<<r<<endl;
}
return ;
} //这样始终过不了,实在是想不明白
#include <iostream>
#include <string>
using namespace std;
string s;
int main()
{
int n, len;
cin>>n;
char r;
while(n--)
{
cin>>s;
len = s.size() - ;
if (len <= )
{
r = '+';
}
else
if (s[len] == '')
{
r = '-';
}
else
if (s[len] == '')
{
r = '*';
}
else
{
r = '?';
}
cout<<r<<endl;
}
return ;
}

846 - Steps

#include <iostream>
#include <cmath>
using namespace std; int main()
{
int t, x, y, ans;
cin>>t;
while(t--)
{
cin>>x>>y;
ans = ;
x = abs(x - y);
if (x <= )
{
ans = x;
}
else
{
y = sqrt(x);
while (x - ( + y) * y / < (y - ) * y / )
{
y--;
}
while (x - ( + y) * y / - (y - ) * y / > )
{
ans++;
x -= y;
}
if (x - ( + y) * y / - (y - ) * y / == )
{
ans++;
}
ans += * y - ;
}
cout<<ans<<endl;
}
return ;
}

573 - The Snail

#include <iostream>

using namespace std;

int main()
{
double h, u, d, f;
int days;
double dis, dre;
while (cin>>h>>u>>d>>f, h)
{
days = ;
dis = ;
dre = u * f / ;
while (true)
{
dis += u;
if (dis > h)
{
cout<<"success on day "<<days<<endl;
break;
}
dis -= d;
if (dis < )
{
cout<<"failure on day "<<days<<endl;
break;
}
u -= dre;
if (u < )
{
u = ;
}
days++;
}
}
return ;
}

10499 - The Land of Justice

#include <iostream>

using namespace std;

int main()
{
long long int n;
while (cin>>n, n >= )
{
if (n <= )
cout<<"0%"<<endl;
else
cout<< * n<<"%"<<endl;
}
return ;
}

10790 - How Many Points of Intersection?

/*
f(a, b)=f(a-1,b)+¡¾(a-1)*(b-1) + 0¡¿* b/2
f(a-1, b)=f(a-2,b)+¡¾(a-2)*(b-1) + 0¡¿* b/2
f(a-2, b)=f(a-3,b)+¡¾(a-3)*(b-1) + 0¡¿* b/2
f(2, b)=0+¡¾(b-1)¡¿* b/2
F(a,b) =(b-1)*b/2 *¡¾1+ ...+ (a-3) + (a-2)+(a-1)¡¿
=(b-1)*(b)/2 * a(a-1)/2
*/
#include <iostream> using namespace std; int main()
{
long long a, b, t = , bb;
while (cin>>a>>b, a | b)
{
if (b & )
{
bb = (b - ) / ;
}
else
{
bb = b / ;
b = b - ;
}
cout<<"Case "<<t++<<": "<<a * (a - ) / * b * bb<<endl;
}
return ;
}

Volume 1. Maths - Misc的更多相关文章

  1. UVA题目分类

    题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...

  2. UVA - 10014 - Simple calculations (经典的数学推导题!!)

    UVA - 10014 Simple calculations Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & ...

  3. Java中实现SAX解析xml文件到MySQL数据库

    大致步骤: 1.Java bean 2.DBHelper.java 3.重写DefaultHandler中的方法:MyHander.java 4.循环写数据库:SAXParserDemo.java ① ...

  4. CSharpGL(8)使用3D纹理渲染体数据 (Volume Rendering) 初探

    CSharpGL(8)使用3D纹理渲染体数据 (Volume Rendering) 初探 2016-08-13 由于CSharpGL一直在更新,现在这个教程已经不适用最新的代码了.CSharpGL源码 ...

  5. 理解Docker(8):Docker 存储之卷(Volume)

    (1)Docker 安装及基本用法 (2)Docker 镜像 (3)Docker 容器的隔离性 - 使用 Linux namespace 隔离容器的运行环境 (4)Docker 容器的隔离性 - 使用 ...

  6. Docker Volume 之权限管理(转)

    Volume数据卷是Docker的一个重要概念.数据卷是可供一个或多个容器使用的特殊目录,可以为容器应用存储提供有价值的特性: 持久化数据与容器的生命周期解耦:在容器删除之后数据卷中的内容可以保持.D ...

  7. sun.misc.BASE64Encoder找不到jar包的解决方法

    1.右键项目->属性->java bulid path->jre System Library->access rules->resolution选择accessible ...

  8. NFS Volume Provider(Part III) - 每天5分钟玩转 OpenStack(64)

    今天我们将前一小节创建的 NFS volume “nfs-vol-1” attach 到 instance “c2”上. 这里我们重点关注 nova-compute 如何将“nfs-vol-1” at ...

  9. NFS Volume Provider(Part II) - 每天5分钟玩转 OpenStack(63)

    上一节我们将 NFS volume provider 配置就绪,本节将创建 volume. 创建 volume 创建 NFS volume 操作方法与 LVM volume 一样,唯一区别是在 vol ...

随机推荐

  1. 11.3NOIP模拟赛

    /* 考虑贪心 把原序列排序后,对于原中位数往后所有比要更改到的值小的都改成它 正确性显然. */ #include<iostream> #include<cstdio> #i ...

  2. [Usaco2012 Open]Balanced Cow Subsets

    Description Farmer John's owns N cows (2 <= N <= 20), where cow i produces M(i) units of milk ...

  3. _bzoj1001 [BeiJing2006]狼抓兔子【平面图】

    传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1001 顺便推荐一个ppt,里面有对平面图的介绍:浅析最大最小定理在信息学竞赛中的应用. 这里 ...

  4. 贪心/思维题 Codeforces Round #310 (Div. 2) C. Case of Matryoshkas

    题目传送门 /* 题意:套娃娃,可以套一个单独的娃娃,或者把最后面的娃娃取出,最后使得0-1-2-...-(n-1),问最少要几步 贪心/思维题:娃娃的状态:取出+套上(2),套上(1), 已套上(0 ...

  5. 题解报告:hdu 1541 Stars(经典BIT)

    Problem Description Astronomers often examine star maps where stars are represented by points on a p ...

  6. 题解报告:hdu 1062 Text Reverse

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1062 Problem Description Ignatius likes to write word ...

  7. Styles and Themens(1)详述

    Styles and Themes IN THIS DOCUMENT Defining Styles Inheritance Style Properties Applying Styles and ...

  8. Bmob使用心得

    1.在 Project 的 build.gradle 文件中添加 Bmob的maven仓库地址,示例如下:(注意文字说明部分): allprojects { repositories { jcente ...

  9. jQuery.ajax() 设置 Headers 中的 Accept 内容

    jQuery.ajax() 如何设置 Headers 中的 Accept 内容   其实很简单,首先如果是常见类型,则请直接设置 dataType 属性 $.ajax({ dataType: &quo ...

  10. qt5.5版本的creator构建套件自动检测为警告

    原创,转载请注明http://www.cnblogs.com/dachen408/p/7226188.html 原因,安装qt在E盘,winsdksetup也在E盘 的原因,卸载winsdksetup ...