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 ...
随机推荐
- bzoj 3159: 决战【LCT】
只是想复健一下LCT没想到做了不得了的题--调了两天QAQ 题解是这么说的: 但是果然还不太理解--因为swap的前后问题调了好久,(所以一开始养成的习惯后面就不要再改啦-- 总之大概就是把对位置lc ...
- WFS1.1.0协议(增删改查)+openlayers4.3.1前端构建+geoserver2.15.1安装部署+shpfile数据源配置
WFS简介 1.WFS即,Web要素服务,全称WebFeatureService.GIS下,支持对地理要素的插入,更新,删除,检索和发现服务. 2.属于OGC标准下的通信协议.OGC标准下的GIS服务 ...
- python删除列表中元素的方法
删除列表中元素的三种方法-remove.pop.del 1 1.remove: 删除单个元素,删除首个符合条件的元素,按值删除 2 举例说明: 3 >>> str=[1,2,3,4, ...
- python之对堆栈、队列处理操作(转载+个人看法)
参考链接:https://blog.csdn.net/u010786109/article/details/40649827 python实现堆栈操作 堆栈是一个后进先出的数据结构,其工作方式就像一堆 ...
- ROS学习笔记八:基于Qt搭建ROS开发环境
1 前言 本文介绍一种Qt下进行ROS开发的完美方案,使用的是ros-industrial的Levi-Armstrong在2015年12月开发的一个Qt插件ros_qtc_plugin,这个插件使得Q ...
- 51nod 1133 不重叠的线段(贪心)
1133 不重叠的线段 基准时间限制:1 秒 空间限制:131072 KB 分值: 10 难度:2级算法题 收藏 关注 X轴上有N条线段,每条线段有1个起点S和终点E.最多能够选出多少条互不重叠 ...
- Jewel Magic UVA - 11996 || bzoj1014: [JSOI2008]火星人prefix
Jewel Magic UVA - 11996 这是一道用splay/非旋treap做的题(这里用的是非旋treap) 1/2/3是splay/非旋treap的常规操作.对于操作4,可以用哈希法求LC ...
- 贪心 CodeForces 124B Permutations
题目传送门 /* 贪心:全排列函数使用,更新最值 */ #include <cstdio> #include <algorithm> #include <cstring& ...
- C#---数据库访问通用类、Access数据库操作类、mysql类 .[转]
原文链接 //C# 数据库访问通用类 (ADO.NET)using System;using System.Collections.Generic;using System.Text;using Sy ...
- 08 H5新增input元素
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...