//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 !!的更多相关文章

  1. UVa 11529 (计数) Strange Tax Calculation

    枚举一个中心点,然后将其他点绕着这个点按照极角排序. 统计这个中心点在外面的三角形的个数,然后用C(n-1, 3)减去这个数就是包含这个点的三角形的数量. 然后再枚举一个起点L,终点为弧度小于π的点R ...

  2. UVA题目分类

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

  3. UVA10519 - !! Really Strange !!(数论+高精度)

    10519 - !! Really Strange !!(数论+高精度) option=com_onlinejudge&Itemid=8&category=24&page=sh ...

  4. uva 11529 - Strange Tax Calculation(计数问题)

    题目链接:uva 11529 - Strange Tax Calculation 题目大意:给出若干个点,保证随意三点不共线.随意选三个点作为三角行,其它点若又在该三角形内,则算是该三角形内部的点.问 ...

  5. uva 11529 Strange Tax Calculation (几何+计数)

    题目链接: http://vjudge.net/problem/viewProblem.action?id=18277 这题暴力n^4妥妥的TLE!即使n^3也可能会T 正确的姿势应该是:枚举每个点作 ...

  6. UVA 12950 : Even Obsession(最短路Dijkstra)

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  7. UVA 1291 十四 Dance Dance Revolution

    Dance Dance Revolution Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Su ...

  8. UVA 10194 (13.08.05)

    :W Problem A: Football (aka Soccer)  The Problem Football the most popular sport in the world (ameri ...

  9. uva 1354 Mobile Computing ——yhx

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5

随机推荐

  1. 29-自己动手构建RequestDelegate管道

    1-使用vsCode新建个项目 2-新建RequestDelegate和Context public delegate Task RequestDelegate(Context context); p ...

  2. 笔记-python-standard library-26.4 unittest

    笔记-python-standard library-26.4 unittest 1.      unittest source code:Lib/unittest/__init__.py 它是pyt ...

  3. Idea搭建spring framework源码环境

    spring的源码目前放在github上,https://github.com/spring-projects/spring-framework 一.安装Git 二.安装Gradle gradle为解 ...

  4. 十二、mysql之视图,触发器,事务等

    一.视图 视图是一个虚拟表(非真实存在),其本质是[根据SQL语句获取动态的数据集,并为其命名],用户使用时只需使用[名称]即可获取结果集,可以将该结果集当做表来使用. 使用视图我们可以把查询过程中的 ...

  5. 4 CSS的20/80个知识点

    1.css的基本构成 样式选择器 id选择器 元素选择器 2.css的盒模型 border padding margin 3.Atom快捷键 4.程序 (1)初始程序 <!DOCTYPE htm ...

  6. Linux下单机安装部署kafka及代码实现

    技术交流群:233513714 这几天研究了kafka的安装及使用,在网上找了很多教程但是均以失败告终,直到最后想起网络方面的问题最终才安装部署成功,下面就介绍一下kafka的安装部署及代码实现 一. ...

  7. Eclipse 创建 XML 文件---Eclipse教程第12课

    打开新建 XML 文件向导 你可以使用新建 XML 文件向导来创建 XML 文件.打开向导的方式有: 点击 File 菜单并选择 New > Other 点击新建下拉框 () 选择 Other ...

  8. 《Cracking the Coding Interview》——第1章:数组和字符串——题目2

    2014-03-18 01:30 题目:反转一个char *型的C/C++字符串. 解法:一头一尾俩iterator,向中间靠拢并且交换字符. 代码: // 1.2 Implement a funct ...

  9. 《数据结构》C++代码 邻接表与邻接矩阵

    上一篇“BFS与DFS”写完,突然意识到这个可能偏离了“数据结构”的主题,所以回来介绍一下图的存储:邻接表和邻接矩阵. 存图有两种方式,邻接矩阵严格说就是一个bool型的二维数组,map[i][j]表 ...

  10. python - web自动化测试 - 元素操作 - 鼠标键盘

    # -*- coding:utf-8 -*- ''' @project: web学习 @author: Jimmy @file: 鼠标操作.py @ide: PyCharm Community Edi ...