2023年NOC大赛加码未来编程赛道-初赛-Python(初中组-卷1)
Posted 青少儿编程课堂
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2023年NOC大赛加码未来编程赛道-初赛-Python(初中组-卷1)相关的知识,希望对你有一定的参考价值。
2023年NOC大赛加码未来编程赛道-初赛-Python(初中组-卷1)
*1.Python自带的编程环境是?
A、PyScripter
B、Spyder
C、Notepad++
D、IDLE
*2.假设a=20,b-3,那么a or b的结果是? ()
A、20
B、0
C.1
D.3
*3.假设a=2,b=3,那么a-b*b的值是?
A、 3
B、-2
C、-7
D、-11
*4.以下选项中不符合 Python变量命名规则的是? ()
A,mame
B、2_to
C、_Go
D、Tea
*5.创建一个新的Python程序,编写了下面的代码 :
import turtle
turtle shapel turtle"保存这个Pvthon文件并且取了文件名,以下哪个文件名程序可以正常运行?
A.trist py
B、turtle.py
C, import. py3
D,hao.sb2
6.执行语句x,y=8%5.8//3后,变量x、y的值分别为? (0)
A、18.2
B、1,2.56665
C,4.2
D,1. 2
7.使用下面中的 ()图致接收辐入的数据
A.accept0)
B、input0)
C, readline!!
D, loginit
*8.8=2.b=3,那么c=a**b运算的结果是? ()
A.6
B、8
C.9
D、23
*9.已知s=list("sgdhasdghasdg”]
2019 年百度之星·程序设计大赛 - 初赛二
1001 度度熊与数字
#pragma comment(linker, "/STACK:36777216")
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);++i)
#define FOR(i,a,b) for(int i=int(a);i<int(b);++i)
#define DWN(i,b,a) for(int i=int(b);i>=int(a);--i)
/// type define
typedef double DB;
typedef long long LL;
typedef std::vector<int>VI;
typedef std::vector<LL>VLL;
typedef std::pair<int, int>PII;
typedef std::pair<LL, LL>PLL;
typedef std::vector<PII >VPII;
/// const
static const double eps = 1e-8;
static const double pi = acos(-1.0);
static const int inf = 0x3f3f3f3f;
static const LL INF = 0x3f3f3f3f3f3f3f3f;
/// common statement
#define PB push_back
#define MP std::make_pair
#define fi first
#define se second
/****************************************************************/
const int maxn = 2e6 + 7;
const LL MOD = 1e9 + 7;
bool chk(LL x, LL n)
int s = 0;
while(n)
s += n % 10;
n /= 10;
return s % x == 0;
void solve()
/*********** start your code here. ************/
LL n;
std::cin >> n;
VI ans;
for(LL x = 1; x * x <= n; ++x)
if(n % x)
continue;
if(chk(x, n))
ans.PB(x);
if(chk(n / x, n) && x != n / x)
ans.PB(n / x);
std::cout << ans.size() << "\n";
std::sort(ans.begin(),ans.end());
for(int i = 0, sz = ans.size(); i < sz; ++i)
std::cout << ans[i] << (i == sz - 1 ? "\n" : " ");
void init()
int main()
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
//init();
int T;
std::cin >> T;
while(T--)
solve();
return 0;
1002 度度熊与排列
#pragma comment(linker, "/STACK:36777216")
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);++i)
#define FOR(i,a,b) for(int i=int(a);i<int(b);++i)
#define DWN(i,b,a) for(int i=int(b);i>=int(a);--i)
/// type define
typedef double DB;
typedef long long LL;
typedef std::vector<int>VI;
typedef std::vector<LL>VLL;
typedef std::pair<int, int>PII;
typedef std::pair<LL, LL>PLL;
typedef std::vector<PII >VPII;
/// const
static const double eps = 1e-8;
static const double pi = acos(-1.0);
static const int inf = 0x3f3f3f3f;
static const LL INF = 0x3f3f3f3f3f3f3f3f;
/// common statement
#define PB push_back
#define MP std::make_pair
#define fi first
#define se second
/****************************************************************/
const int maxn = 1e3 + 7;
const LL MOD = 1e9 + 7;
int mat[maxn][maxn];
void parse(std::string is, std::string os)
int sz = is.length();
REP(i, sz)REP(j, sz)if(is[i] == os[j])
mat[i][j]++;
std::vector<int>edges[maxn];
bool vis[maxn];
int boy[maxn];
int gril[maxn];
bool dfs(int v)
int len = edges[v].size();
for(int i = 0; i < len; i++)
int end = edges[v][i];
if(!vis[end])
vis[end] = 1;
if(boy[end] == 0 || dfs(boy[end]))
boy[end] = v;
gril[v] = end;
return 1;
return 0;
void solve()
/*********** start your code here. ************/
int n, m;
std::cin >> n >> m;
std::cin.get();
REP(i, maxn)REP(j, maxn) mat[i][j] = 0;
for(int i = 0; i < n; ++i)
std::string is, os;
getline(std::cin, is);
getline(std::cin, os);
parse(is, os);
REP(i,m) edges[i].clear();
REP(i, m)REP(j, m)
mat[i][j] = mat[i][j] == n ? n : 0;
if(mat[i][j])
edges[i].PB(j);
//REP(i,m) REP(j,m) std::cout << mat[i][j] << (j == m-1 ? "\n" : " ");
int ans = 0;
memset(boy,0,sizeof(boy));
for(int i = m - 1; i >= 0; i--)
memset(vis, 0, sizeof(vis));
if(dfs(i))
ans++;
if(ans != m)
std::cout << "-1\n";
else
REP(i,m)std::cout << gril[i]+1 << (i == m-1 ? "\n" : " ");
void init()
int main()
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
//init();
int T;
std::cin >> T;
while(T--)
solve();
return 0;
1003 度度熊与运算式 1
#pragma comment(linker, "/STACK:36777216")
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);++i)
#define FOR(i,a,b) for(int i=int(a);i<int(b);++i)
#define DWN(i,b,a) for(int i=int(b);i>=int(a);--i)
/// type define
typedef double DB;
typedef long long LL;
typedef std::vector<int>VI;
typedef std::vector<LL>VLL;
typedef std::pair<int, int>PII;
typedef std::pair<LL, LL>PLL;
typedef std::vector<PII >VPII;
/// const
static const double eps = 1e-8;
static const double pi = acos(-1.0);
static const int inf = 0x3f3f3f3f;
static const LL INF = 0x3f3f3f3f3f3f3f3f;
/// common statement
#define PB push_back
#define MP std::make_pair
#define fi first
#define se second
/****************************************************************/
const int maxn = 1e6 + 7;
const LL MOD = 1e9 + 7;
VI ans(maxn);
int cal(const char *str)
int t, cur = 0;
ans.clear();
ans.PB(1);
for(int i = 0, sz = strlen(str); i < sz; i++)
switch(str[i])
case '?':
ans[cur]++;
break;
case '^':
ans.PB(1);
cur++;
break;
int ret(0);
//for(auto i : ans) std::cout << i << " ";
//std::cout << "\n";
int b[32] = 0;
memset(b, 0, sizeof(b));
for(auto i : ans)
for(int j = 30; j > 0; --j)
if(i & (1 << j))
b[j]++;
for(int i = 30; i > 0; --i)
if(b[i] )
b[i - 1] += (b[i] - 1)*2;
b[i] = 1, ret |= (1 << i);
ret |= ((strlen(str) + 1 & 1) ? 1 : 0);
return ret;
void solve()
/*********** start your code here. ************/
std::string str, fs;
getline(std::cin, str);
std::cout << cal(str.c_str()) << "\n";
void init()
int main()
std::ios::sync_with_stdio(false);
std::cin.tie(0);
//init();
int T;
std::cin >> T;
std::cin.get();
while(T--)
solve();
return 0;
以上是关于2023年NOC大赛加码未来编程赛道-初赛-Python(初中组-卷1)的主要内容,如果未能解决你的问题,请参考以下文章