1. //ans=2*n+(n-1)(n-2) n>=2
    #include <map>
  2. #include <set>
  3. #include <list>
  4. #include <cmath>
  5. #include <ctime>
  6. #include <deque>
  7. #include <stack>
  8. #include <queue>
  9. #include <cctype>
  10. #include <cstdio>
  11. #include <string>
  12. #include <vector>
  13. #include <climits>
  14. #include <cstdlib>
  15. #include <cstring>
  16. #include <iostream>
  17. #include <algorithm>
  18. #define LL long long
  19. #define PI 3.1415926535897932626
  20. using namespace std;
  21. int gcd(int a, int b) {return a % b == ? b : gcd(b, a % b);}
  22. const int numlen=;
  23. struct bign {
  24. int len, s[numlen];
  25. bign() {
  26. memset(s, , sizeof(s));
  27. len = ;
  28. }
  29. bign(int num) { *this = num; }
  30. bign(const char *num) { *this = num; }
  31. bign operator = (const int num) {
  32. char s[numlen];
  33. sprintf(s, "%d", num);
  34. *this = s;
  35. return *this;
  36. }
  37. bign operator = (const char *num) {
  38. len = strlen(num);
  39. while(len > && num[] == '') num++, len--;
  40. for(int i = ;i < len; i++) s[i] = num[len-i-] - '';
  41. return *this;
  42. }
  43.  
  44. void deal() {
  45. while(len > && !s[len-]) len--;
  46. }
  47.  
  48. bign operator + (const bign &a) const {
  49. bign ret;
  50. ret.len = ;
  51. int top = max(len, a.len) , add = ;
  52. for(int i = ;add || i < top; i++) {
  53. int now = add;
  54. if(i < len) now += s[i];
  55. if(i < a.len) now += a.s[i];
  56. ret.s[ret.len++] = now%;
  57. add = now/;
  58. }
  59. return ret;
  60. }
  61. bign operator - (const bign &a) const {
  62. bign ret;
  63. ret.len = ;
  64. int cal = ;
  65. for(int i = ;i < len; i++) {
  66. int now = s[i] - cal;
  67. if(i < a.len) now -= a.s[i];
  68. if(now >= ) cal = ;
  69. else {
  70. cal = ; now += ;
  71. }
  72. ret.s[ret.len++] = now;
  73. }
  74. ret.deal();
  75. return ret;
  76. }
  77. bign operator * (const bign &a) const {
  78. bign ret;
  79. ret.len = len + a.len;
  80. for(int i = ;i < len; i++) {
  81. for(int j = ;j < a.len; j++)
  82. ret.s[i+j] += s[i]*a.s[j];
  83. }
  84. for(int i = ;i < ret.len; i++) {
  85. ret.s[i+] += ret.s[i]/;
  86. ret.s[i] %= ;
  87. }
  88. ret.deal();
  89. return ret;
  90. }
  91.  
  92. bign operator * (const int num) {
  93. // printf("num = %d\n", num);
  94. bign ret;
  95. ret.len = ;
  96. int bb = ;
  97. for(int i = ;i < len; i++) {
  98. int now = bb + s[i]*num;
  99. ret.s[ret.len++] = now%;
  100. bb = now/;
  101. }
  102. while(bb) {
  103. ret.s[ret.len++] = bb % ;
  104. bb /= ;
  105. }
  106. ret.deal();
  107. return ret;
  108. }
  109.  
  110. bign operator / (const bign &a) const {
  111. bign ret, cur = ;
  112. ret.len = len;
  113. for(int i = len-;i >= ; i--) {
  114. cur = cur*;
  115. cur.s[] = s[i];
  116. while(cur >= a) {
  117. cur -= a;
  118. ret.s[i]++;
  119. }
  120. }
  121. ret.deal();
  122. return ret;
  123. }
  124.  
  125. bign operator % (const bign &a) const {
  126. bign b = *this / a;
  127. return *this - b*a;
  128. }
  129.  
  130. bign operator += (const bign &a) { *this = *this + a; return *this; }
  131. bign operator -= (const bign &a) { *this = *this - a; return *this; }
  132. bign operator *= (const bign &a) { *this = *this * a; return *this; }
  133. bign operator /= (const bign &a) { *this = *this / a; return *this; }
  134. bign operator %= (const bign &a) { *this = *this % a; return *this; }
  135.  
  136. bool operator < (const bign &a) const {
  137. if(len != a.len) return len < a.len;
  138. for(int i = len-;i >= ; i--) if(s[i] != a.s[i])
  139. return s[i] < a.s[i];
  140. return false;
  141. }
  142. bool operator > (const bign &a) const { return a < *this; }
  143. bool operator <= (const bign &a) const { return !(*this > a); }
  144. bool operator >= (const bign &a) const { return !(*this < a); }
  145. bool operator == (const bign &a) const { return !(*this > a || *this < a); }
  146. bool operator != (const bign &a) const { return *this > a || *this < a; }
  147.  
  148. string str() const {
  149. string ret = "";
  150. for(int i = ;i < len; i++) ret = char(s[i] + '') + ret;
  151. return ret;
  152. }
  153. };
  154. istream& operator >> (istream &in, bign &x) {
  155. string s;
  156. in >> s;
  157. x = s.c_str();
  158. return in;
  159. }
  160. ostream& operator << (ostream &out, const bign &x) {
  161. out << x.str();
  162. return out;
  163. }
  164. bign ans,t;
  165. int main()
  166. {
  167. while (cin>>t)
  168. {
  169. if (t==) {puts("");continue;}
  170. if (t==) {puts("");continue;}
  171. ans=t+t;
  172. bign n1=t-;
  173. bign n2=t-;
  174. n1=n1*n2;
  175. ans+=n1;
  176. cout<<ans<<endl;
  177. }
  178. return ;
  179. }

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. java8之list集合中取出某一属性的方法

    上代码 List<User> list = new ArrayList<User>(); User user1 = new User("第一位"," ...

  2. POJ:1258-Agri-Net

    Agri-Net Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 65322 Accepted: 27029 Descriptio ...

  3. POJ 3580 SuperMemo 伸展树

    题意: 维护一个序列,支持如下几种操作: ADD x y D:将区间\([x,y]\)的数加上\(D\) REVERSE x y:翻转区间\([x,y]\) REVOLVE x y T:将区间\([x ...

  4. 10.bootstrap分页,点击哪个分页号,哪个分页号就active

    1.分页,点击哪个分页号,哪个分页号就active <nav> <ul class="pagination"> <li><a href=& ...

  5. Windows系统安装测试redis

    因本人电脑是windows系统,从https://github.com/ServiceStack/redis-windows下载了兼容windows系统的redis 下载后直接解压到D:\redis目 ...

  6. Hadoop 原理总结

    Hadoop 原理总结   一.Hadoop技术原理 Hdfs主要模块:NameNode.DataNode Yarn主要模块:ResourceManager.NodeManager 常用命令: 1)用 ...

  7. php 升级php5.5 、php7

    rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm yum install php55w php55w-opcache yum install ...

  8. PJMEDIA之录音器的使用(capture sound to avi file)

    为了熟悉pjmedia的相关函数以及使用方法,这里练习了官网上的一个录音器的例子. 核心函数: pj_status_t pjmedia_wav_writer_port_create ( pj_pool ...

  9. linux下给开启端口

    首先在这里要推荐一篇博文 http://blog.csdn.net/zht666/article/details/17505789 这篇文章写的很详细,里面包含了操作端口一些命令,我们操作端口其实就是 ...

  10. 常用模块(datatime)

    import datetime,time# dt = datetime.datetime.now() # 获取当前时间的时间对象# dt = datetime.date.fromtimestamp(t ...