当前位置:网站首页>[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;
}
边栏推荐
- Codeforces 771-div2 C (trouble, permutation is not very good)
- [I'm a mound pytorch tutorial] learning notes
- AAAI 2022 | Peking University & Ali Dharma Institute: pruning and compression of pre training language model based on comparative learning
- 趣味 面试题
- Calculate the maximum path sum of binary tree
- AI中台技术调研
- Interview with meituan, a 34 year old programmer, was rejected: only those under the age of 30 who work hard and earn little overtime
- Sse/avx instruction set and API of SIMD
- LeetCode—<动态规划专项>剑指 Offer 19、49、60
- [FFH] little bear driver calling process (take calling LED light driver as an example)
猜你喜欢
Simple use of drools decision table
Heap (priority queue)
高性能纠删码编码
[old horse of industrial control] detailed explanation of Siemens PLC TCP protocol
The programmer and the female nurse went on a blind date and spent 360. He packed leftovers and was stunned when he received wechat at night
This "little routine" is set on the dough cake of instant noodles. No wonder programmers are always hungry
CDH存在隐患 : 该角色的进程使用的交换内存为xx兆字节。警告阈值:200字节
AI中台技术调研
Thesis translation: 2022_ PACDNN: A phase-aware composite deep neural network for speech enhancement
Mysql database foundation
随机推荐
考研英语二大作文模板/图表作文,英语图表作文这一篇就够了
Calculate the maximum path sum of binary tree
Sub thread get request
Fastdateformat why thread safe
Writing method of then part in drools
JZ63 股票的最大利润
Docker-compose配置Mysql,Redis,MongoDB
mysql数据库基础
Error in kubeadm join: [error port-10250]: port 10250 is in use [error fileavailable--etc kubernetes PKI
LeetCode—剑指 Offer 51. 数组中的逆序对
kubenetes中port、targetPort、nodePort、containerPort的区别与联系
Distributed machine learning framework and high-dimensional real-time recommendation system
This "little routine" is set on the dough cake of instant noodles. No wonder programmers are always hungry
String palindrome hash template question o (1) judge whether the string is palindrome
CDA数据分析——Excel数据处理的常见知识点归纳
Simple use of drools decision table
Anxiety of a 211 programmer: working for 3 years with a monthly salary of less than 30000, worried about being replaced by fresh students
Why do programmers have the idea that code can run without moving? Is it poisonous? Or what?
Go learning notes - multithreading
Leetcode122 the best time to buy and sell stocks II