题解 AT934 【完全数】

关于 AT934 【完全数】

本来是查一道别的题的,

nonetheless,

however,

whereas,

but,

我在哪一篇文章也用了这四个词?(#^.^#)

映入眼帘,

列表第二个,614提交,96通过(算不算我?)

这不重要,

入门难度 ??????!!!!!!

进去一看,哦

日文啊,原来如此

原什么呀!有翻译好不好,网页提示谷歌/有道翻译好不好!

对,好烂的借口

闭嘴,说那么多干什么!让你讲题!!!

~~是咧,我错了(。﹏。*)~~

哼(¬︿??¬☆),讲就讲

壹.

数据范围要想想,可爱的10^10哦

so : long long;

思路很简单,大致就是循环枚举因数然后加起来

完全平方数的一个因数会被统计两次,需要减去,呵呵( ̄▽ ̄)"

贰.

就这样交上去,

然后then ,

啪!!!

无比可爱(●'?'●)的“1”甩手给你一巴掌。

面向数据编程的大佬告诉你要特判。

叁.

我是凑戏的!!!

肆.

程序在此:是AC代码吗


#include<bits/stdc++.h>

using namespace std; 

long long n;
long long sum=0;
long long square_root;
int main()
{
    scanf("%lld",&n);
    if(n==1)
    {
        printf("Deficient\n");
        return 0;
    }
    square_root=sqrt(n);
    for(long long i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            sum+=i;
            sum+=n/i;
        }
    }
    sum-=n;
    if(square_root*square_root==n)
    {
        sum-=square_root;
    }
    if(sum==n)
    {
        printf("Perfect\n");
    }
    else if(sum<n)
    {
        printf("Deficient\n");
    }
    else printf("Abundant\n");
    return 0;
}

就这样。

谢谢!!!


柔肠百转,庭前春花别枝头,芳华匆促逝,叶触犹伤,只剩琴音未阑。掬土埋香骨,从此尘缘茫茫,端路几许,香茔怎忘?淡淡地无奈成为了遥远的轮回。季节的寻踪里,有无限的花儿凋零残落,梦里流年依旧,唯一不变的是来生与你再续的承诺。

A hundred turns, before the court, the spring flower leaves the branch, the fragrant flower is fleeting, the leaf touch is still injured, only the piano is left. With the soil buried in the bone, from then on the boundless dust, the end of the road a few, how to forget the tomb? Indifferent to become a distant return. In the pursuit of the season, there are infinite flowers and litter, the dream is still in the year, the only constant is the promise of the afterlife and the continuation of you.

柔肠百转、庭先の春の花別こずえ、芳華慌ただしくて、葉に触れ、傷、あと琴音未手すり。埋香掬土骨端以来、俗世の因縁は広大で、道はいくらか、香墓場ど忘れ?冷ややかに無力になって遠い輪廻。季節の中にあって、無限の花が散り落ち、夢の中で年回りは、唯一不変は来世あなたと再続の承諾。

转载于:https://www.cnblogs.com/XSZCaesar/p/10549477.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
题目描述: 给出两个非空链表来表示两个非负整数。其中,它们各自的位数是按照逆序的方式存储的,并且它们的每个节点只能存储一位数字。 如果,我们将这两个数相加起来,则会返回一个新的链表来表示它们的和。 您可以假设除了数字 0 之外,这两个数都不会以零开头。 示例: 输入:(2 -> 4 -> 3) + (5 -> 6 -> 4) 输出:7 -> 0 -> 8 原因:342 + 465 = 807 解题思路: 题目中要求我们按照逆序的方式存储两个非负整数,也就是说链表的头节点表示该数的个位,第二个节点表示该数的十位,以此类推。 因此,我们可以从两个链表的头节点开始,对应位相加,并记录进位,将结果添加到新的链表中。如果有进位,需要在下一位相加时加上进位。 需要注意的是,当两个链表的长度不一致时,可以将较短的链表的缺失位看作是 0。 最后,如果最高位有进位,还需要在新链表的最高位添加一个值为 1 的节点。 C 语言代码实现: /** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ struct ListNode* addTwoNumbers(struct ListNode* l1, struct ListNode* l2){ struct ListNode *head = NULL, *tail = NULL; int carry = 0; while (l1 || l2) { int n1 = l1 ? l1->val : 0; int n2 = l2 ? l2->val : 0; int sum = n1 + n2 + carry; if (!head) { head = tail = malloc(sizeof(struct ListNode)); tail->val = sum % 10; tail->next = NULL; } else { tail->next = malloc(sizeof(struct ListNode)); tail = tail->next; tail->val = sum % 10; tail->next = NULL; } carry = sum / 10; if (l1) l1 = l1->next; if (l2) l2 = l2->next; } if (carry > 0) { tail->next = malloc(sizeof(struct ListNode)); tail = tail->next; tail->val = carry; tail->next = NULL; } return head; }

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值