当前位置:网站首页>[ybtoj advanced training guidance] judgment overflow [error]
[ybtoj advanced training guidance] judgment overflow [error]
2022-07-02 12:32:00 【VL—MOESR】

Ideas :
Because it will exceed the boundary , Then transfer the form of multiplication to the form of division
( I originally wanted to practice with this problem c++ String input , The result didn't come out )
c o d e ( w r o n g ) code(wrong) code(wrong)
#include<iostream>
#include<cstdio>
using namespace std;
int t;
int main()
{
scanf("%d ", &t);
while(t--)
{
unsigned long long i;
string s="", ss="", s1="";
getline(cin, s1);
for(i=0; ; i++)
{
s=s+s1[i];
if(s=="int8"||
s=="unsigned int8"||
s=="int16"||
s=="unsigned int16"||
s=="int32"||
s=="unsigned int32"||
s=="int64"||
s=="unsigned int64")
break;
}
i+=2;
for(; i<s1.size(); i++)
ss=ss+s1[i];
unsigned long long maxx;
if(s=="int8")
maxx=127;
if(s=="unsigned int8")
maxx=255;
if(s=="int16")
maxx=32767;
if(s=="unsigned int16")
maxx=65535;
if(s=="int32")
maxx=2147483647;
if(s=="unsigned int32")
maxx=4294967295;
if(s=="int64")
maxx=9223372036854775807;
if(s=="unsigned int64")
maxx=18446744073709551615;
i=0;
unsigned long long sum=1, flag=1, j=0;
while(j<ss.size())
{
unsigned long long b=0;
for(; j<ss.size()&&ss[j]!=' '; j++)
b=b*10+ss[j]-48;
unsigned long long last=sum;
sum*=b;
i++;
if(sum>maxx||sum<0||sum/b!=last)
{
flag=0;
break;
}
j++;
}
if(flag==1)
printf("never\n");
else printf("%d\n", i);
}
return 0;
}
边栏推荐
- LeetCode—剑指 Offer 37、38
- 子线程获取Request
- Go learning notes - multithreading
- Interview with meituan, a 34 year old programmer, was rejected: only those under the age of 30 who work hard and earn little overtime
- drools执行完某个规则后终止别的规则执行
- Simple use of drools decision table
- PyTorch nn. Full analysis of RNN parameters
- 深拷贝 事件总线
- Drools executes string rules or executes a rule file
- In development, why do you find someone who is paid more than you but doesn't write any code?
猜你喜欢

MySQL与PostgreSQL抓取慢sql的方法

Lekao: 22 year first-class fire engineer "technical practice" knowledge points

Find the common ancestor of any two numbers in a binary tree
![[FFH] little bear driver calling process (take calling LED light driver as an example)](/img/e7/153ae9f1befc12825d277620049f9d.jpg)
[FFH] little bear driver calling process (take calling LED light driver as an example)

Sparkcontext: error initializing sparkcontext solution

【工控老马】西门子PLC Siemens PLC TCP协议详解

MySQL and PostgreSQL methods to grab slow SQL

Simple use of drools decision table

Sweetheart leader: Wang Xinling

使用Sqoop把ADS层数据导出到MySQL
随机推荐
Drools terminates the execution of other rules after executing one rule
lombok常用注解
CDA数据分析——Excel数据处理的常见知识点归纳
二分刷题记录(洛谷题单)区间的甄别
Sparkcontext: error initializing sparkcontext solution
drools中then部分的写法
Jenkins user rights management
BOM DOM
LeetCode—剑指 Offer 37、38
The differences and relationships among port, targetport, nodeport and containerport in kubenetes
考研英语二大作文模板/图表作文,英语图表作文这一篇就够了
CDA data analysis -- common knowledge points induction of Excel data processing
Leetcode - Sword finger offer 51 Reverse pairs in an array
Map和Set
CV2 in OpenCV VideoWriter_ Fourcc() function and cv2 Combined use of videowriter() function
LeetCode—剑指 Offer 59 - I、59 - II
IPhone 6 plus is listed in Apple's "retro products" list
使用Sqoop把ADS层数据导出到MySQL
Docker compose configuration mysql, redis, mongodb
堆(優先級隊列)