Volume 1. Maths - Misc
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;
}
}
} }
#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 ;
}
#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 ;
}
#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 ;
}
//这样就过了
#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 ;
}
#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 ;
}
#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 ;
}
#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的更多相关文章
- UVA题目分类
题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...
- UVA - 10014 - Simple calculations (经典的数学推导题!!)
UVA - 10014 Simple calculations Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & ...
- Java中实现SAX解析xml文件到MySQL数据库
大致步骤: 1.Java bean 2.DBHelper.java 3.重写DefaultHandler中的方法:MyHander.java 4.循环写数据库:SAXParserDemo.java ① ...
- CSharpGL(8)使用3D纹理渲染体数据 (Volume Rendering) 初探
CSharpGL(8)使用3D纹理渲染体数据 (Volume Rendering) 初探 2016-08-13 由于CSharpGL一直在更新,现在这个教程已经不适用最新的代码了.CSharpGL源码 ...
- 理解Docker(8):Docker 存储之卷(Volume)
(1)Docker 安装及基本用法 (2)Docker 镜像 (3)Docker 容器的隔离性 - 使用 Linux namespace 隔离容器的运行环境 (4)Docker 容器的隔离性 - 使用 ...
- Docker Volume 之权限管理(转)
Volume数据卷是Docker的一个重要概念.数据卷是可供一个或多个容器使用的特殊目录,可以为容器应用存储提供有价值的特性: 持久化数据与容器的生命周期解耦:在容器删除之后数据卷中的内容可以保持.D ...
- sun.misc.BASE64Encoder找不到jar包的解决方法
1.右键项目->属性->java bulid path->jre System Library->access rules->resolution选择accessible ...
- NFS Volume Provider(Part III) - 每天5分钟玩转 OpenStack(64)
今天我们将前一小节创建的 NFS volume “nfs-vol-1” attach 到 instance “c2”上. 这里我们重点关注 nova-compute 如何将“nfs-vol-1” at ...
- NFS Volume Provider(Part II) - 每天5分钟玩转 OpenStack(63)
上一节我们将 NFS volume provider 配置就绪,本节将创建 volume. 创建 volume 创建 NFS volume 操作方法与 LVM volume 一样,唯一区别是在 vol ...
随机推荐
- 洛谷P2221 [HAOI2012]高速公路(线段树+概率期望)
传送门 首先,答案等于$$ans=\sum_{i=l}^r\sum_{j=i}^r\frac{sum(i,j)}{C_{r-l+1}^2}$$ 也就是说所有情况的和除以总的情况数 因为这是一条链,我们 ...
- js 编码详解
今天在整理 js编码解码方法时,在网上搜资料,发现一篇文章讲的不错,讲解的非常简单明了,于是乎就想转载过来,却发现无法转载到博客园,最后只能卑鄙的摘抄过来.js编码解码就是将一些对URL和数据库敏感的 ...
- codeforces 570 E. Pig and Palindromes (DP)
题目链接: 570 E. Pig and Palindromes 题目描述: 有一个n*m的矩阵,每个小格子里面都有一个字母.Peppa the Pig想要从(1,1)到(n, m).因为Peppa ...
- _bzoj1031 [JSOI2007]字符加密Cipher【后缀数组】
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1031 保存后缀数组模版. 其实如果数据范围小一点,或者空间限制再大一点,或者甚至只要字母表再 ...
- _bzoj1003 [ZJOI2006]物流运输【预处理】
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1003 预处理出第i天到第j天走一条航线时的最短路. #include <cstdio& ...
- 链表中用标兵结点简化代码 分类: c/c++ 2014-09-29 23:10 475人阅读 评论(0) 收藏
标兵结点(头结点)是在链表中的第一个结点,不存放数据,仅仅是个标记 利用标兵结点可以简化代码.下面实现双向链表中的按值删除元素的函数,分别实现 带标兵结点和不带标兵结点两版本,对比可见标兵结点的好处. ...
- sdut1642Simple Arithmetics(模拟)
链接 发个长长的模拟 这题要注意的地方挺多 -的个数 以及对齐的情况 全都注意好了 大数的加减乘就可以了 #include <iostream> #include<cstdio> ...
- webform 基础一
WebForm是微软开发的一款产品,它将用户的请求和响应都封装为控件.让开发者认为自己是在操作一个windows界面.极大地提高了开发效率.区别于dreamweaver,可以用代码写,也可以把控件像w ...
- [BZOJ1005][HNOI2008]明明的烦恼 数学+prufer序列+高精度
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; int N; ...
- oracle 创建表
--创建表 create table browser_track( btId number not null , opend_id ) not null, url_address ) not null ...