Wannafly 15 Problem A 直角三棱锥
本文最后更新于 2084 天前,其中的信息可能已经有所发展或是发生改变。

内容纲要

题解

题目可以转化为插板法求解。考虑当$x + y + z <= k$时满足题意,引入一个$a$ 变成了$x + y + z + a = k$然后我们需要求的便是${k+3}\choose{3}$。
注意到题目的数据范围,可以用__int128解决问题。

AC代码

#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <array>

using ll = long long;
using namespace std;
using lll = __int128;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int T;
    cin >> T;
    while(T--)
    {
        ll k,m;
        cin >> k >> m;
        lll ans = k + 1;
        cout << (ll)(ans * (ans + 1) * (ans + 2) / 6 % m) << "\n";
    }
}
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇