spinmry's Lab

绝赞摸鱼中Orz

Category

  • Algorithm
  • Hardware
  • Homelab
  • Programming
  • Retro
  • Software

Tags

  • 算法
  • OI
  • Linux
  • 数据结构
  • HardwareHacking
  • 计算设备
  • Vintage
  • 图论
  • Kruskal
  • 平衡树
  • RobotC
  • 单片机
  • QQBot
  • 离散化
  • Nspire
  • 线段树
  • VEX
  • 机器人
  • Homelab
  • 树状数组
  • ARM
  • 爬虫
  • ACG
  • 分块
  • Wolfram
  • 网页
  • Mattermost
  • 数论
  • CUDA
  • STM32
  • Python
  • iLO
  • 动态规划
  • Tarjan
  • Loongson

Recent replies

  • jiyouzhan 发表于「使用 Debian + libvirt + WebVirtCloud 作为 homelab 虚拟化平台」
  • jianchen 发表于「在 Loongson 2F 上编译 Common Desktop Environment」
  • rantrism 发表于「解决 Linux Optimus 混合模式下独立显卡外接显示器卡顿的问题」
  • 千羽 发表于「在 Loongson 2F 上编译 Common Desktop Environment」
  • spinmry 发表于「QQ - Mattermost 双向转发机器人」

友情链接

空白酱
Woshiluo
FlyGoat
BeyondLimits
Memo von EFS
Paizhang
Ntzyz
ZephRay
Polarnova
Tautcany
NekoDaemon
MaxAlex
Abyss Studio
EE Archeology 电子考古学
桜庭清夏的小站
欠陥電気の摸鱼小池
白玉楼製作所
naivekun's blog

娱乐向跑分

Coremark
Linpack
标签:数论

Luogu 4932 浏览器

2019 年 3 月 21 日分类:Algorithm#算法#数论#OI

Luogu 4932 浏览器

这道题是某次 Luogu 月赛的题目。关于这道题的代码,非常神奇的是,这是比赛时某学长看到管理员提交记录的编译信息中含有一句神奇的内建函数 __builtin_popcount() ,然后根据那句话反推出来的。(喂喂喂这算作弊吧) 下面是 GNU 对这个函数的定义

    
    — Built-in Function: 
    int __builtin_popcount (unsigned int x)
    Returns the number of 1-bits in x.

然后是代码

    
    // luogu-judger-enable-o2
    #include <iostream>
    #include <cstdio>                                                       
    using namespace std; //define                                           
    unsigned long long ans[3],n,a,b,c,d,x; //main
    int main(){
        ios::sync_with_stdio(false);
        cin>>n>>a>>b>>c>>d>>x;                                                      
        for(int i=1;i<=n;i++){
            x=(a%d*(x%d*x%d)+b*x%d+c)%d;ans[__builtin_popcount(x)&1]++;
        }
        cout<<ans[0]*ans[1]<<endl;
        return 0;
    }

Comments

xkzzzz: 大家好我是传说中的学长

  • «
  • 1
  • »
Copyright © 2019-2023 spinmry. All rights reserved.
Except where otherwise noted, content on this blog is licensed under CC BY-SA 4.0.