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. 洛谷P4216 [SCOI2015]情报传递(树剖+主席树)

    传送门 我们可以进行离线处理,把每一个情报员的权值设为它开始收集情报的时间 那么设询问的时间为$t$,就是问路径上有多少个情报员的权值小于等于$t-c-1$ 这个只要用主席树上树就可以解决了,顺便用树 ...

  2. Vue父子组件传值之——访问根组件$root、$parent、$children和$refs

    Vue组件传值除了prop和$emit,我们还可以直接获取组件对象: 根组件: $root // 单一对象 表示当前组件树的根 Vue 实例,即new Vue({...根组件内容}).如果当前实例没有 ...

  3. 手机APP测试点总结(参考)

    参考链接:http://www.zengyuetian.com/?p=2305 手机APP测试点: 功能测试:多注意核心业务风险(如:注册.登录.付费.订单等) 兼容性测试:系统兼容性.硬件兼容性.软 ...

  4. docker 端口被占用问题解决

    启动容器A, A的端口映射是 80:8080 外部的25000端口映射到服务内部的8080端口:有时候将容器关闭,重新构建镜像及启动容器时会出现一些报错, 比如端口被占用的报错,但通过docker p ...

  5. MyEclipse中Tomcat对应JVM的参数配置

    MyEclipse中Tomcat对应JVM的参数配置: -Xmx512M -Xms256M -XX:MaxPermSize=256m

  6. 216 Combination Sum III 组合总和 III

    找出所有可能的 k 个数,使其相加之和为 n,只允许使用数字1-9,并且每一种组合中的数字是唯一的.示例 1:输入: k = 3, n = 7输出:[[1,2,4]]示例 2:输入: k = 3, n ...

  7. [转]无废话SharePoint入门教程一[SharePoint概述]

    本文转自:http://www.cnblogs.com/iamlilinfeng/p/3026332.html 一.前言 听说SharePoint也有一段时间了,可一直处在门外.最近被调到ShareP ...

  8. Oracle中的序列

    序列是什么? 序列是用来生成唯一.连续的整数的数据库对象.序列通常用来自动生成主键或唯一键的值.序列可以按升序排列,也可以按照降序排列. 其实Oracle中的序列和MySQL中的自增长差不多一个意思. ...

  9. SpringSecurity的简单使用

    导入SpringSecurity坐标 在web.xml中配置过滤器 编写spring-securiy配置文件 编写自定义认证提供者 用户新增时加密密码 配置页面的login和logout 获取登录用户 ...

  10. GIT配置及用法

    ssh配置 TortoiseGit配置 用法: 下面是我整理的常用 Git 命令清单.几个专用名词的译名如下. Workspace:工作区 Index / Stage:暂存区 Repository:仓 ...