题解 | 智乃的数字

智乃的数字

https://www.nowcoder.com/practice/8f1b8129db30467787167da1a589b324

观察发现智数每过7个增加30。{3,5,9,15,21,25,27}是增加的类循环

#include <iostream>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int d[]={0,3,5,9,15,21,25};
    int t;
    cin>>t;
    while(t--){
        long long k;
        cin>>k;
        long long res;
        if(k%7)res=(k/7)*30+d[k%7];
        else res=(k/7)*30-3;
        cout<<res<<"\n";
    }
    return 0;
}

全部评论

相关推荐

小牛炒肉:好大的官威居然不是什么官
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务