zoukankan      html  css  js  c++  java
  • [NOIp2017提高组]小凯的疑惑

    题目大意:
      给你两个数a,b,保证a与b互质,求最大的x满足不能被表示成若干个a与b的和。

    思路:
      据说是小学奥数题。
      考场上先写了个a*b的60分DP,然后打表发现答案就是(a-1)*(b-1)-1。

     1 #include<cstdio>
     2 #include<cctype>
     3 typedef long long int64;
     4 inline int getint() {
     5     register char ch;
     6     while(!isdigit(ch=getchar()));
     7     register int x=ch^'0';
     8     while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0');
     9     return x;
    10 }
    11 int main() {
    12     printf("%lld
    ",(int64)(getint()-1)*(getint()-1)-1);
    13     return 0;
    14 }
  • 相关阅读:
    poj 2251
    poj 1321
    poj 2777
    poj 3468
    poj 2318
    javascript
    buhui
    swift 构造器
    mac上不了网
    字体
  • 原文地址:https://www.cnblogs.com/skylee03/p/7819736.html
Copyright © 2011-2022 走看看