UVA 10519 !! Really Strange !!
- //ans=2*n+(n-1)(n-2) n>=2
#include <map>- #include <set>
- #include <list>
- #include <cmath>
- #include <ctime>
- #include <deque>
- #include <stack>
- #include <queue>
- #include <cctype>
- #include <cstdio>
- #include <string>
- #include <vector>
- #include <climits>
- #include <cstdlib>
- #include <cstring>
- #include <iostream>
- #include <algorithm>
- #define LL long long
- #define PI 3.1415926535897932626
- using namespace std;
- int gcd(int a, int b) {return a % b == ? b : gcd(b, a % b);}
- const int numlen=;
- struct bign {
- int len, s[numlen];
- bign() {
- memset(s, , sizeof(s));
- len = ;
- }
- bign(int num) { *this = num; }
- bign(const char *num) { *this = num; }
- bign operator = (const int num) {
- char s[numlen];
- sprintf(s, "%d", num);
- *this = s;
- return *this;
- }
- bign operator = (const char *num) {
- len = strlen(num);
- while(len > && num[] == '') num++, len--;
- for(int i = ;i < len; i++) s[i] = num[len-i-] - '';
- return *this;
- }
- void deal() {
- while(len > && !s[len-]) len--;
- }
- bign operator + (const bign &a) const {
- bign ret;
- ret.len = ;
- int top = max(len, a.len) , add = ;
- for(int i = ;add || i < top; i++) {
- int now = add;
- if(i < len) now += s[i];
- if(i < a.len) now += a.s[i];
- ret.s[ret.len++] = now%;
- add = now/;
- }
- return ret;
- }
- bign operator - (const bign &a) const {
- bign ret;
- ret.len = ;
- int cal = ;
- for(int i = ;i < len; i++) {
- int now = s[i] - cal;
- if(i < a.len) now -= a.s[i];
- if(now >= ) cal = ;
- else {
- cal = ; now += ;
- }
- ret.s[ret.len++] = now;
- }
- ret.deal();
- return ret;
- }
- bign operator * (const bign &a) const {
- bign ret;
- ret.len = len + a.len;
- for(int i = ;i < len; i++) {
- for(int j = ;j < a.len; j++)
- ret.s[i+j] += s[i]*a.s[j];
- }
- for(int i = ;i < ret.len; i++) {
- ret.s[i+] += ret.s[i]/;
- ret.s[i] %= ;
- }
- ret.deal();
- return ret;
- }
- bign operator * (const int num) {
- // printf("num = %d\n", num);
- bign ret;
- ret.len = ;
- int bb = ;
- for(int i = ;i < len; i++) {
- int now = bb + s[i]*num;
- ret.s[ret.len++] = now%;
- bb = now/;
- }
- while(bb) {
- ret.s[ret.len++] = bb % ;
- bb /= ;
- }
- ret.deal();
- return ret;
- }
- bign operator / (const bign &a) const {
- bign ret, cur = ;
- ret.len = len;
- for(int i = len-;i >= ; i--) {
- cur = cur*;
- cur.s[] = s[i];
- while(cur >= a) {
- cur -= a;
- ret.s[i]++;
- }
- }
- ret.deal();
- return ret;
- }
- bign operator % (const bign &a) const {
- bign b = *this / a;
- return *this - b*a;
- }
- bign operator += (const bign &a) { *this = *this + a; return *this; }
- bign operator -= (const bign &a) { *this = *this - a; return *this; }
- bign operator *= (const bign &a) { *this = *this * a; return *this; }
- bign operator /= (const bign &a) { *this = *this / a; return *this; }
- bign operator %= (const bign &a) { *this = *this % a; return *this; }
- bool operator < (const bign &a) const {
- if(len != a.len) return len < a.len;
- for(int i = len-;i >= ; i--) if(s[i] != a.s[i])
- return s[i] < a.s[i];
- return false;
- }
- bool operator > (const bign &a) const { return a < *this; }
- bool operator <= (const bign &a) const { return !(*this > a); }
- bool operator >= (const bign &a) const { return !(*this < a); }
- bool operator == (const bign &a) const { return !(*this > a || *this < a); }
- bool operator != (const bign &a) const { return *this > a || *this < a; }
- string str() const {
- string ret = "";
- for(int i = ;i < len; i++) ret = char(s[i] + '') + ret;
- return ret;
- }
- };
- istream& operator >> (istream &in, bign &x) {
- string s;
- in >> s;
- x = s.c_str();
- return in;
- }
- ostream& operator << (ostream &out, const bign &x) {
- out << x.str();
- return out;
- }
- bign ans,t;
- int main()
- {
- while (cin>>t)
- {
- if (t==) {puts("");continue;}
- if (t==) {puts("");continue;}
- ans=t+t;
- bign n1=t-;
- bign n2=t-;
- n1=n1*n2;
- ans+=n1;
- cout<<ans<<endl;
- }
- return ;
- }
UVA 10519 !! Really Strange !!的更多相关文章
- UVa 11529 (计数) Strange Tax Calculation
枚举一个中心点,然后将其他点绕着这个点按照极角排序. 统计这个中心点在外面的三角形的个数,然后用C(n-1, 3)减去这个数就是包含这个点的三角形的数量. 然后再枚举一个起点L,终点为弧度小于π的点R ...
- UVA题目分类
题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...
- UVA10519 - !! Really Strange !!(数论+高精度)
10519 - !! Really Strange !!(数论+高精度) option=com_onlinejudge&Itemid=8&category=24&page=sh ...
- uva 11529 - Strange Tax Calculation(计数问题)
题目链接:uva 11529 - Strange Tax Calculation 题目大意:给出若干个点,保证随意三点不共线.随意选三个点作为三角行,其它点若又在该三角形内,则算是该三角形内部的点.问 ...
- uva 11529 Strange Tax Calculation (几何+计数)
题目链接: http://vjudge.net/problem/viewProblem.action?id=18277 这题暴力n^4妥妥的TLE!即使n^3也可能会T 正确的姿势应该是:枚举每个点作 ...
- UVA 12950 : Even Obsession(最短路Dijkstra)
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- UVA 1291 十四 Dance Dance Revolution
Dance Dance Revolution Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Su ...
- UVA 10194 (13.08.05)
:W Problem A: Football (aka Soccer) The Problem Football the most popular sport in the world (ameri ...
- uva 1354 Mobile Computing ——yhx
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5
随机推荐
- java8之list集合中取出某一属性的方法
上代码 List<User> list = new ArrayList<User>(); User user1 = new User("第一位"," ...
- POJ:1258-Agri-Net
Agri-Net Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 65322 Accepted: 27029 Descriptio ...
- POJ 3580 SuperMemo 伸展树
题意: 维护一个序列,支持如下几种操作: ADD x y D:将区间\([x,y]\)的数加上\(D\) REVERSE x y:翻转区间\([x,y]\) REVOLVE x y T:将区间\([x ...
- 10.bootstrap分页,点击哪个分页号,哪个分页号就active
1.分页,点击哪个分页号,哪个分页号就active <nav> <ul class="pagination"> <li><a href=& ...
- Windows系统安装测试redis
因本人电脑是windows系统,从https://github.com/ServiceStack/redis-windows下载了兼容windows系统的redis 下载后直接解压到D:\redis目 ...
- Hadoop 原理总结
Hadoop 原理总结 一.Hadoop技术原理 Hdfs主要模块:NameNode.DataNode Yarn主要模块:ResourceManager.NodeManager 常用命令: 1)用 ...
- php 升级php5.5 、php7
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm yum install php55w php55w-opcache yum install ...
- PJMEDIA之录音器的使用(capture sound to avi file)
为了熟悉pjmedia的相关函数以及使用方法,这里练习了官网上的一个录音器的例子. 核心函数: pj_status_t pjmedia_wav_writer_port_create ( pj_pool ...
- linux下给开启端口
首先在这里要推荐一篇博文 http://blog.csdn.net/zht666/article/details/17505789 这篇文章写的很详细,里面包含了操作端口一些命令,我们操作端口其实就是 ...
- 常用模块(datatime)
import datetime,time# dt = datetime.datetime.now() # 获取当前时间的时间对象# dt = datetime.date.fromtimestamp(t ...