Skip to content

Commit

Permalink
牛客小白月赛98
Browse files Browse the repository at this point in the history
  • Loading branch information
SnowDreamXUE committed Jul 13, 2024
1 parent 1a478db commit 7b473f7
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 0 deletions.
38 changes: 38 additions & 0 deletions 牛客/牛客小白月赛98/A.骰子魔术.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
骰子魔术

https://ac.nowcoder.com/acm/contest/85598/A

有一个一样的色子就可以

```cpp
// By SnowDream
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+10;

int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,x;
cin >> n >> x;
int a;
bool ans= false;
for(int i=0;i<n;++i)
{
cin >> a;
if(a==x)
{
ans=true;
}
}
if(ans)
cout << "YES";
else
cout << "NO";
cout << "\n";
return 0;
}
```

52 changes: 52 additions & 0 deletions 牛客/牛客小白月赛98/B.最少剩几个?.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
最少剩几个?

https://ac.nowcoder.com/acm/contest/85598/B

计算奇偶数数量,先一奇一偶对消,再两奇对消

```cpp
// By SnowDream
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+10;
int a[N];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,s1=0,s2=0;
cin >> n;
for(int i=0;i<n;++i)
{
cin >> a[i];
if(a[i]%2==0)
{
s2++;
}
else
{
s1++;
}
}
if(s1==s2)
{
cout << 0;
}
else if(s1<s2)
{
cout << s2-s1;
}
else
{
int tmp=s1-s2;
if(tmp%2==0)
cout << 0;
else
cout << 1;
}
cout << "\n";
return 0;
}
```

38 changes: 38 additions & 0 deletions 牛客/牛客小白月赛98/C.两个函数.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
两个函数

https://ac.nowcoder.com/acm/contest/85598/C

数学方程化简

```cpp
// By SnowDream
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+10;
ll a,x;
ll fun()
{
if(x==1)
{
return a%998244353;
}
ll tmp1 = a*a%998244353;
ll tmp2 = (x*(x-1))/2%998244353;
return tmp1*tmp2%998244353;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while(t--)
{
cin >> a >> x;
cout << fun() << "\n";
}
return 0;
}
```

0 comments on commit 7b473f7

Please sign in to comment.