codeforces 1091D. New Year and the Permutation Concatenation 打表

基于Simulink的占空比调制DTC降低转矩脉动 修改传统SVPWM模块,输入占空比d和有效矢量索引,计算Ton​=d∗Tc​、Toff​=(1−d)∗Tc​,生成对称PWM波形(替代开关表直接输出)。:低速时(n<500rpm)减小dmax​=0.6(避免磁链畸变),高速时(n>2000rpm)增大dmax​=0.8(提升动态响应);kT​/kψ​:转矩/磁链误差增益(需整定,如kT​=0.02/(N⋅m),kψ​=0.1/Wb);(θ为电压矢量与磁链夹角)。② SVM-DTC(占空比计算模块启用,d0​=0.5,kT​=0.02,kψ​=0.1)。 阅读详情

题意:输入一个数 n(1,1000000),n 的全排列组成的集合 A,长度为 n*n!,在集合 A 中,输出所有长度为 n 的子集中数字和为 n*(n+1)/2 的子集个数。

思路:用 dfs 打表找规律,发现 ans[n] = n! + ans[n-1]*n。

AC代码:

#include<bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define per(i,a,n) for (int i=a;i<n;i++)
#define rep(i,a,n) for (int i=n-1;i>=a;i--)
#define show(x) cout<<x<<endl;
#define showEnd(x)   cout<<x<<endl; return 0;
#define show_(x)    cout<<x<<" ";
#define showxy(x,y) cout<<x<<" "<<y<<endl;
typedef long long ll;
const int maxn = 1000005;
const int INF = 0x3f3f3f3f;
const int MOD = 998244353;

int i,j,n;
ll a[maxn],b[maxn];

int main()
{
    IO
    while(cin>>n)
    {
        a[0] = 1,b[0] = 1;
        for(i = 1; i <= n; i++)
        {
            b[i] = i*b[i-1]%MOD;
            ll temp = a[i-1] - 1;
            a[i] = (b[i]%MOD + i*temp%MOD)%MOD;
//            showxy(a[i], b[i])
        }
        show(a[n])
    }

    return 0;
}

打表代码:

#include<bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define per(i,a,n) for (int i=a;i<n;i++)
#define rep(i,a,n) for (int i=n-1;i>=a;i--)
#define show(x) cout<<x<<endl;
#define showEnd(x)   cout<<x<<endl; return 0;
#define show_(x)    cout<<x<<" ";
#define showxy(x, y)  cout<<x<<" "<<y<<endl;
typedef long long ll;
const int maxn = 1000005;
const int INF = 0x3f3f3f3f;
const int MOD = 998244353;

int i,j,n,vis[maxn],perm[maxn],ans;
vector<int> v;

void dfs(int step)
{
    if(step == n+1)
    {
        for(int i = 1; i <= n; i++)
        {
            v.push_back(perm[i]);
        }
    }
    for(int i = 1; i <= n; i++)
    {
        if(!vis[i])
        {
            vis[i] = 1;
            perm[step] = i;
            dfs(step+1);
            vis[i] = 0;
        }
    }
}

int main()
{
    IO
    while(cin>>n)
    {
        memset(vis, 0, sizeof(vis));
        ans = 0;
        v.clear();
        dfs(1);
        for(i = 0; i < v.size(); i++)
        {
            int temp = 0;
            for(j = i; j < i+n; j++)
            {
                temp += v[j];
            }
            if(temp == (n*(n+1)/2))   ans++;
        }
        show(ans)
    }

    return 0;
}

 

SAP B1中文培訓教材_SDK 公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说 立即下载

相关推荐

RimWorld Mod开发避坑指南:从Defs命名规范到XML结构详解(附实战代码)

本文深入解析RimWorld Mod开发中Defs文件的编写规范与高级技巧,涵盖命名冲突预防、XML结构优化及高级功能实现。通过实战代码示例,帮助开发者避开常见陷阱,提升Mod兼容性与稳定性,特别适合RimWorld Mod开发者参考。

weixin_30790841的博客 453

CodeForces - 1091D New Year and the Permutation Concatenation (打表)

????‍♂️ ????‍♂️ ????‍♂️ 首先可以写出来这样的打表代码: vi x,y; inline void solve(int n) { x.clear();y.clear(); rpp(i,n) x.push_back(i); do { for(auto i:x) y.push_back(i); } while (next_permutation...

欢迎光临 我的心 228

OBD诊断协议:OBDⅡ (SAE J1979) 和 OBDonUDS (SAE J1979-2) 和ZEV OBD技术架构的详细对比

摘要:文章对比了2025年最新OBD技术标准(SAEJ1979系列)的三大架构:传统OBD-II(已淘汰)、OBDonUDS(燃油/混动车)和ZEVOBD(新能源车)。核心发现:1)OBDonUDS与ZEVOBD共享UDS协议栈和DoIP通信标准,仅应用层数据(DID/DTC)不同;2)物理层统一为CAN+以太网,支持远程诊断和OTA;3)诊断工具需同时兼容J1979-2/3数据库。技术演进呈现"协议统一化、数据专用化"趋势,2027年后所有新车将强制采用新标准。

m0_56482679的博客 2403

【Codeforces 1091D】New Year and the Permutation Concatenation

【链接】 我是链接,点我呀:) 【题意】 把1~n的n!种排列依次连接成一个长度为nn!的序列。 让你在这个序列当中找长度为n的连续段,使得连续段中的数字的和为n(n-1)/2 输出符合要求的连续段的个数 【题解】 也就是让你找到长度为n的连续段,然后里面1~n各出现一次 考虑相邻的两个排列 设他们有长度为i的相同前缀 例如 xxabcxxcba 会发现我们用第二个排列的...

209

Unity面试题总结

Unity面试题

sinat_34014668的博客 1万+

从零开始:用ADS仿真设计一个2.4GHz Wi-Fi低噪声放大器(含完整电路图)

本文提供了一份详细的ADS软件仿真指南,手把手教你从零开始设计一个2.4GHz Wi-Fi低噪声放大器。内容涵盖核心指标理解、晶体管选型与建模、匹配网络设计、偏置电路集成,并通过S参数仿真、噪声优化及线性度验证等步骤,最终呈现完整的优化电路图,助力射频初学者掌握LNA设计全流程。

weixin_29197835的博客 807

[cf 1091D]D. New Year and the Permutation Concatenation

再次看了下两年前的题解,觉得还蛮有意思的hhh。不过在一些部分可能表述没那么好。写一份修正版的。 题意:给定n!n!n!个nnn的排列,按字典序从小到大连成一个序列,例如3的情况为:[1,2,3, 1,3,2, 2,1,3 ,2,3,1 ,3,1,2 ,3,2,1]。问其中子段长度为n,且和sum=n×(n−1)÷2sum=n\times(n-1)\div2sum=n×(n−1)÷2的序列有多少? (题意来自于:https://www.cnblogs.com/pkgunboat/archive/2018/1

aiqiyizz的博客 209

跟着团子学SAP CO:基于成本的完工百分比结算:Cost-based POC(以项目为例)

本文以英国及北美会计准则下的基于成本的POC的销售型项目结算对PS模块中的完工百分比进行介绍

Lucas1211的博客 2万+

codeforces 1091D New Year and the Permutation Concatenation 组合数

D. New Year and the Permutation Concatenation time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Let nn be an integer. Consider all ...

include的背后是微不足道的开始 706

rk3568 点亮双LVDS 屏

承接文章《rk3568点亮LCD(lvds)》中仅仅只能使用亮单LVDS;经过厂商的努力,陆续发布新补丁。目前支持双lvds显示,缺憾是需要自己额外移植相关补丁。受限于通信频率和VOP编码能力,支持最大分辨仍然是1920x1080、60fps。

weixin_35723192的博客 3008

TC3XX - MCAL知识点(一):新建Tc3xx EB-tresos工程

基于EB-tresos建立Hightec或者Tasking工程的时候,第一个步骤就是需要新建一个EB-tresos的工程,本文记录一下如何新建一个EB-tresos工程,以及对其进行简单的操作。那么Tc3xx的MCAL包含哪些内容呢?

梦想技术家 2977

【CodeForces 1091D --- New Year and the Permutation Concatenation】DP+全排列思想+思维

【CodeForces 1091D --- New Year and the Permutation Concatenation】DP+全排列思想+组合数 题目来源:点击进入【CodeForces 1091D — New Year and the Permutation Concatenation】 Description Let n be an integer. Consider all per...

来日浅谈的博客 768

基于simulink的预测电流控制策略的三相逆变器仿真

本文详细介绍了在Simulink中实现基于预测电流控制策略的三相逆变器仿真方法。主要内容包括:准备工作(安装必要软件及工具箱)、构建三相逆变器基础模型、设计预测电流控制器(包含状态空间建模和控制器设计)、实现控制逻辑、添加示波器观察输出、配置仿真参数以及运行仿真分析结果。通过MATLAB代码示例和Simulink模块说明,展示了如何选择最优开关状态来最小化电流误差。该仿真方法为研究快速响应、高精度的逆变器控制提供了实用工具,但需注意实际应用中可能需要的调试工作。

amy_mhd的博客 278

CodeForces - 1091D New Year and the Permutation Concatenation【数学】

D. New Year and the Permutation Concatenation time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Let nn be an integer. Consider all ...

微微风簇浪,散作满河星 656

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

D. New Year and the Permutation Concatenation (数学题)

http://codeforces.com/problemset/problem/1091/DD. New Year and the Permutation Concatenation time limit per test 2 seconds memory limit per test 256 megabytes input standard input output stand...

ccsu_deer 785

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

Good Bye 2018 D. New Year and the Permutation Concatenation

题目链接:https://codeforces.com/problemset/problem/1091/D 题目大意: 给定数字n,把n的全排列按字典序放入p数组中,这个数组的长度即n*n!.问你这个p数组中有多少这样的段,一段里的数字之和为n(n+1)/2.结果取模1e9 + 7. 解题思路: 明显地,1+2+…+n = n*(n+1)/2.盲目地找肯定是不行的,必须要有点规律下手。题目有说明“...

CourierLo的博客 188

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

New Year and the Permutation Concatenation

https://codeforces.com/contest/1091/problem/D /* *@Author: STZG *@Language: C++ */ #include &lt;bits/stdc++.h&gt; #include&lt;iostream&gt; #include&lt;algorithm&gt; #include&lt;cstdlib&gt; #includ...

无限迭代中...... 532

D. New Year and the Permutation Concatenation 题解翻译+思路解释(官方为主,我为补充)+普通人能看得懂的代码(我照着思路写的哈哈哈)

传送门:http://codeforces.com/contest/1091/problem/D There are two types of subarrays with length n: 有两种类型的长度为n的子序列 They are fully formed from one permutations. 所组成的元素完全就是来自某一个独立的排列 They are a concate...

qq_40822492的博客 597

Codeforces Good Bye 2018 D (1091D) New Year and the Permutation Concatenation

题意:给n!个n的排列,按字典序从小到大连成一条序列,例如3的情况为:[1,2,3,1,3,2,2,1,3,2,3,1,3,1,2,3,2,1],问其中长度为n,且和为sum=n*(n+1)/2的序列有多少个? 思路(官方题解):我们考虑一下next_perumation函数产生字典序递增的全排列的过程: 假设某一个序列长度为n,最长的递减的后缀长度k,那么它的下一个排列是这样产生的...

weixin_30794491的博客 142

Good Bye 2018-D. New Year and the Permutation Concatenation

地址:http://codeforces.com/contest/1091/problem/D 思路:规律题,比赛时一看就想到是规律题,但是一直没找到规律,看了别人的代码才发现是和前一个值有关     i=1  f[i]=1        i=2  f[i]=2=2!+0                0=2*(1-1)         i=3  f[i]=9=3!+3        ...

随风而行的博客 633

codeforces-1119D

题意:给你一个a数组,a数组每次每个数都加一,有q次查询每一查询加L次到加R次中出现的所有不重复的数字个数。 题解:先将a数组排序,在将a和a+1的差值算出来,然后将差值排序,然后再将差值求前缀和,这个代表在没有增加的情况下有多少个不同的数字,然后每次查询的时候,将前缀和加上增加后的出现的新数字的个数就是答案。 #include<bits/stdc++.h> #define ll...

Zhengggggg的博客 410

codeforce 1091

题目连接:http://codeforces.com/contest/1091 A: #include &lt;bits/stdc++.h&gt; using namespace std; int main() { int y, b, r; cin &gt;&gt; y &gt;&gt; b &gt;&gt; r; cout &lt;&lt; min(y, min(b - 1, r -...

梦醒了 477

D. New Year and the Permutation Concatenation(打表找规律/思维+排列组合)

https://codeforces.com/problemset/problem/1091/D 思路: 看到的时候就感觉是规律题。 打表之后oeis发现没规律。尝试减去一些东西。 首先由于n!是必存在的,所以减去之后,因为是On,所以尝试递推。发现是n*(f[n-1]-1) #include<iostream> #include<vector> #include<queue> #include<cstring> #include<cmath

代码笔记本 228

D. New Year and the Permutation Concatenation(排列组合)

有两种长度n的子序列对答案有贡献有两种长度n的子序列对答案有贡献有两种长度n的子序列对答案有贡献 Ⅰ.因为题目序列由n!个排列拼接而来,所以这n!个排列一定满足题意Ⅰ.因为题目序列由n!个排列拼接而来,所以这n!个排列一定满足题意Ⅰ.因为题目序列由n!个排列拼接而来,所以这n!个排列一定满足题意 Ⅱ.否则,我们一定是往第i个排列选后x个,往i+1个排列拿前n−x个Ⅱ.否则,我们一定是往第i个排列选后x个,往i+1个排列拿前n-x个Ⅱ.否则,我们一定是往第i个排列选后x个,往i+1个排列拿前n−x个 此时如果

jziwjxjd的博客 738

codeforces 再见场 Good Bye 2018 前四题题解

一场下来只出了四题,后四题竟毫无思路……还是太菜了 十一分钟出四题,膜爆tourist   A:New Year and the Christmas Ornament (1091A) 直接把a+2,b+1,c拿出来取最小值就是最终答案里面最大的那个数的上限了,然后乘三减三输出即可。 B:New Year and the Treasure Geolocation (1091B) 考虑到题...

temp06的博客 295

CodeForces - 500B New Year Permutation floyd+选择排序

User ainta has a permutation p1, p2, ..., pn. As the New Year is coming, he wants to make his permutation as pretty as possible. Permutation a1, a2, ..., an is prettier than permutation b1, b2, ..., ...

还我笑颜 373
上一篇: codeforces-1068C-Colored Rooks-图论构造
下一篇: codeforces Codeforces Round #530 (Div. 2) 1099 D Sum in the tree
cutedumpling
博客等级 码龄10年 6粉丝 47原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值