POJ 3982 序列 塔尔苏斯问题解决
而且还加入了大量的主题,直接或模板Java我们能够在水。
除了循环33它的时间,计算A99它是第几,输出准确回答。
#include <stdio.h>
#include <string>
#include <algorithm>
using std::string; const int MAX_B = 5120;
char buf[MAX_B];
int id = 0, len = 0; inline char getFromBuf()
{
if (id >= len)
{
len = fread(buf, 1, MAX_B, stdin);
id = 0;
}
return buf[id++];
} void getIntFromBuf(string &n)
{
char a = getFromBuf();
while ((a == ' ' || a == '\n') && len) a = getFromBuf(); n.clear();
while ((a != ' ' && a != '\n') && len)//老是写&&,错成||
{
n.push_back(a);
a = getFromBuf();
}
} string operator+(string &a, string &b)
{
string c;
int N1 = (int)a.size(), N2 = (int)b.size();
int carry = 0;
for (int i = N1-1, j = N2-1; i>=0 || j>=0 || carry; i--, j--)
{
int an = i>=0? a[i]-'0' : 0;
int bn = j>=0? b[j]-'0' : 0;
int sum = an + bn + carry;
carry = sum / 10;
c.push_back(sum % 10 + '0');
}
reverse(c.begin(), c.end());
return c;
} int main()
{
string a1, a2, a3;
while (true)
{
getIntFromBuf(a1);
if (len == 0) break;
getIntFromBuf(a2);
getIntFromBuf(a3); for (int i = 0; i < 33; i++)
{
string a = a2 + a3;
a1 = a1 + a;
if (i == 32) break;
a2 = a1 + a;
a3 = a3 + a1;
a3 = a3 + a2;
}
puts(a1.c_str());
}
return 0;
}
版权声明:笔者心脏靖,景空间地址:http://blog.csdn.net/kenden23/,可能不会在未经作者同意转载。
POJ 3982 序列 塔尔苏斯问题解决的更多相关文章
- Poj 3982 序列
1.Link: http://poj.org/problem?id=3982 2.Content: 序列 Time Limit: 1000MS Memory Limit: 65536K Total ...
- POJ 3982 序列(JAVA,简单,大数)
题目 //在主类中 main 方法必须是 public static void 的,在 main 中调用非static类时会有警告信息, //可以先建立对象,然后通过对象调用方法: import ja ...
- UVA 10494-If We Were a Child Again(一流的塔尔苏斯)
Problem C If We Were a Child Again Input: standard input Output: standard output seconds "Oo ...
- HDU - 5186 - zhx's submissions (精密塔尔苏斯)
zhx's submissions Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- hdu 2243 考研路茫茫——单词情结 ac自动机+矩阵快速幂
链接:http://acm.hdu.edu.cn/showproblem.php?pid=2243 题意:给定N(1<= N < 6)个长度不超过5的词根,问长度不超过L(L <23 ...
- PlantUML——2.中文乱码及解决
关于中文 参见: http://plantuml.sourceforge.net/unicode.html 问题描述 第一步:创建demo03.txt描述文档: @startuml Alice - ...
- nhibernate实体类主键ID赋值问题
有个同事忽然来找我,说他遇到了一个问题,在调用nhibernate 进行update数据的时候报错,说是有数据行锁定. 看代码,没啥问题. 直接在PL/SQL developer里对数据库进行插入,也 ...
- 2013 ACM/ICPC Asia Regional Changsha Online - J
原题戳这里. 题意: 有一未知列数a1,a2,a3.....an, 已知s[i]=a[i-1]+a[i]+a[i] (1<i<n) s[1]=a[1]+a[2]; s[n]=a[n-1] ...
- 把一个序列转换成非严格递增序列的最小花费 POJ 3666
//把一个序列转换成非严格递增序列的最小花费 POJ 3666 //dp[i][j]:把第i个数转成第j小的数,最小花费 #include <iostream> #include < ...
随机推荐
- registerWithTouchDispatcher()函数的使用
registerWithTouchDispatcher()函数的使用 registerWithTouchDispatcher()函数主要用于注册Touch事件. 当我们使用this->setTo ...
- Android编程心得-Service数据绑定初步
在Android里,Service的数据绑定是一种重要的用法,我们知道Service与Activity一样是运行在当前应用进程的主线程里面的,他们之间交互的方式有多种,下面我来介绍一下如何使用数据绑定 ...
- 从PCI上读取数据 线程和定时器效率
从PCI上读取数据 线程和定时器效率 线程: mythread=AfxBeginThread(StartContinuous,(LPVOID)1,THREAD_PRIORITY_NORMAL,0,CR ...
- SecureCRT 6.7.1 注冊机 和谐 破解 补丁 方法
之前一直在用SecureCRT 6.5.3 版本号,和谐补丁也好找,甚至中文版本号也可找到(眼下仅仅找到了SecureCRT.6.2.0) 可是换为 6.7.1 后就怎么也注冊不了了.. 没办法试了各 ...
- Yii/Yii2:查询返回以某特定列为索引(键)的数组
在Yii1.x中,要想查询语句返回以特定列为键(key)的数组数据,代码例如以下(下述样例以表主键为返回数组索引): $users = User::model()->findAll(array( ...
- swift-辞典NSDictionary定义,变化的关键,删/加入关键
// Playground - noun: a place where people can play import UIKit //--------------------------------- ...
- php文件操作基本使用方法
<?php /* $fp=fopen("tmp.html","r"); $str=fread($fp,filesize("tmp.html&qu ...
- Codeforces Round #264 (Div. 2) C Gargari and Bishops 【暴力】
称号: 意甲冠军:给定一个矩阵,每格我们有一个数,然后把两个大象,我希望能够吃的对角线上的所有数字.我问两个最大的大象可以吃值. 分析:这种想法是暴力的主题,计算出每一格放象的话能得到多少钱,然后求出 ...
- 【NO.3】 c program to caculate and display sum of two matrix
source code: #include "stdafx.h" /* display sum of two matrix*/ int _tmain(int argc, _TCHA ...
- Quick Tip: How to Add Syntax Highlighting to Any Project
Quick Tip: How to Add Syntax Highlighting to Any Projectpublic String showAllArticleForPage() throws ...