zoukankan      html  css  js  c++  java
  • while(~scanf("%d", &n)) 和 while(scanf("%d", &n), n) 有啥不同

    额............我也不知道(先记下)

    printf("%d ", (scanf("%d", &n), n))

    printf("%d ", (~scanf("%d", &n)));

    打印结果都相同........

    测试题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1787

    测试代码:

    代码参考博客:https://blog.csdn.net/ydd97/article/details/47168351

    #include <iostream>
    #include <vector>
    #include <cstdio>
    #define ll long long
    
    using namespace std;
    
    
    ll euler(ll n) {
        int ret = n;
        for (int i = 2; i * i <= n; i++) {
            if (n%i==0) {
                ret -= ret / i;
                while(n%i == 0) {
                    n /= i; 
                }
            }
        }
        
        if (n > 1) ret -= ret / n;
        return ret;
    }
    
    int main() {
        int n;
    //    printf("%lld
    ", (scanf("%d", &n), n));
    //    printf("%lld
    ", (~scanf("%d", &n)));
         while(scanf("%d", &n), n) {
    //    while(~scanf("%d", &n)) {
            printf("%d
    ", n-euler(n)-1);
        }
        return 0;
    }

     今天看到一篇博客:

     可能也是这样想的。然后就没有然后了

  • 相关阅读:
    long类型和int类型的区别!!!!!
    Java-冒号的作用
    Java Scanner类
    jre安装过程
    76. 最小覆盖子串
    75. 颜色分类
    73. 矩阵置零
    72. 编辑距离
    71. 简化路径
    61. 旋转链表
  • 原文地址:https://www.cnblogs.com/hello-dummy/p/13349362.html
Copyright © 2011-2022 走看看