PAT甲级考前整理一:https://www.cnblogs.com/jlyg/p/7525244.html,主要讲了131题的易错题及坑点

PAT甲级考前整理二:https://www.cnblogs.com/jlyg/p/10364696.html,主要讲了考前注意以及一些常用算法。

1132题:用字符串接收会毕竟快,使用atoi函数转成数字,注意a*b会超出int32。

#include<iostream>
#include<cstdio>
#include<set>
#include<map>
#include<vector>
#include<iterator>
#include<algorithm>
#include<cstring>
using namespace std;

int main()
{
    #ifdef ONLINE_JUDGE
    #else
        freopen("test.txt","r",stdin);
    #endif
    int t;
    scanf("%d",&t);
    while(t--)
    {
        char str[20];
        scanf("%s",str);
        char str1[20],str2[20];
        int len = strlen(str);
        strncpy(str1,str,len/2);
        str1[len/2]='\0';
        strcpy(str2,str+len/2);
        int a = atoi(str1),b=atoi(str2);
        int c = atoi(str);
        //a*b超出int32
        if(a*b<=0||c%(a*b)) printf("No\n");
        else printf("Yes\n");
    }
    return 0;
}
View Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-13
  • 2022-01-02
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
相关资源
相似解决方案