【60天计划】
刷洛谷(题单广场) and Acwing算法基础课
P5710
【深基3.例2】数的性质
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e6;
int main()
{
ios;
int n;
cin>>n;
if(!(n&1)&&n>4&&n<=12)
cout<<1<<' ';
else
cout<<0<<' ';
if(!(n&1)||(n>4&&n<=12))
cout<<1<<' ';
else
cout<<0<<' ';
if((!(n&1)&&(n<=4&&n>12))||((n&1)&&n>4&&n<=12))
cout<<1<<' ';
else
cout<<0<<' ';
if((n&1)&&(n<=4||n>12))
cout<<1<<' ';
else
cout<<0<<' ';
}
P5711
【深基3.例3】闰年判断
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e6;
int main()
{
ios;
int n;
cin>>n;
if((n%4==0&&n%100!=0)||n%400==0)
cout<<1;
else
cout<<0;
cout<<"\n";
}
P5712
【深基3.例4】Apples
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e6;
int main()
{
ios;
int n;
cin>>n;
if(n>1)
cout<<"Today, I ate "<
P5713
【深基3.例5】洛谷团队系统
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e6;
int main()
{
ios;
int n;
cin>>n;
int a = n*5;
int b = n*3+11;
if(a
P5714
【深基3.例7】肥胖问题
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e6;
int main()
{
ios;
double m,n;
cin>>m>>n;
double q = m/(n*n);
if(q<18.5)
cout<<"Underweight"<<"\n";
else if(q>=18.5&&q<24)
cout<<"Normal"<<"\n";
else
cout<
P5715
【深基3.例8】三位数排序
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e6;
int main()
{
ios;
int s[10];
for(int i = 0;i<3;i++)
cin>>s[i];
sort(s,s+3);
for(int i = 0;i<3;i++)
cout<
P5716
【深基3.例9】月份天数
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e6;
int r[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
int p[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int main()
{
ios;
int year,month;
cin>>year>>month;
if((year%4==0&&year%100!=0)||year%400==0)
cout<
P1085
[NOIP2004 普及组] 不高兴的津津
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e6;
int main()
{
ios;
int d = 0;
int q = 0;
for(int i = 1;i<=7;i++)
{
int a,b;
cin>>a>>b;
if(a+b>8)
{
if(q
P1909
[NOIP2016 普及组] 买铅笔
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e6;
int main()
{
ios;
int n;
cin>>n;
int ans = inf;
for(int i = 1;i<=3;i++)
{
int a,b;
cin>>a>>b;
ans = min(ans,(n+a-1)/a*b);
}
cout<
P1055
[NOIP2008 普及组] ISBN 号码
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e6;
int main()
{
ios;
char s[15];
cin>>s;
int ans = 0;
int q = 1;
for(int i = 0;i<11;i++)
{
if(s[i]!='-')
{
ans += (s[i]-'0')*q;
q++;
}
}
ans%=11;
if(ans==s[12]-'0'||(ans==10&&s[12]=='X'))
cout<<"Right"<<"\n";
else
{
for(int i = 0;i<12;i++)
cout<
P1422
小玉家的电费
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e6;
int main()
{
ios;
int n;
cin>>n;
double ans = 0;
if(n<=150)
ans+=n*0.4463;
else if(n>150&&n<401)
{
ans+=150*0.4463;
ans+=(n-150)*0.4663;
}
else
{
ans+=150*0.4463;
ans+=(400-150)*0.4663;
ans+=(n-400)*0.5663;
}
printf("%.1lf\n",ans);
}
P1424
小鱼的航程(改进版)
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e6;
int main()
{
ios;
int n,x;
cin>>x>>n;
int go = n/7 * 5;
int r = n%7;
if(r)
{
if(r+x==7||x==7)
r--;
else if(r+x>7)
r-=2;
}
cout<<(go+r)*250<<"\n";
}
P1888
三角函数
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e6;
int main()
{
int s[5];
for(int i = 1;i<=3;i++)
cin>>s[i];
sort(s+1,s+4);
int a = s[1];
int b = s[3];
for(int i = 2;i*i<=b;i++)
{
if(a%i==0&&b%i==0)
{
a/=i;
b/=i;
}
}
cout<
P1046
[NOIP2005 普及组] 陶陶摘苹果
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e6;
int main()
{
int s[15];
for(int i = 1;i<=10;i++)
cin>>s[i];
int mx;
cin>>mx;
mx+=30;
int ans = 0;
for(int i = 1;i<=10;i++)
if(s[i]<=mx)
ans++;
cout<
P5717
【深基3.习8】三角形分类
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e6;
int main()
{
int s[5];
for(int i = 0;i<3;i++)
cin>>s[i];
sort(s,s+3);
if(s[0]+s[1]>s[2]&&s[1]+s[2]>s[0]&&s[0]+s[2]>s[1])
{
;
}
else
{
cout<<"Not triangle"<<"\n";
return 0;
}
int a = s[0]*s[0];
int b = s[1]*s[1];
int c = s[2]*s[2];
int add = a+b;
if(add>c)
cout<<"Acute triangle"<<"\n";
else if(add==c)
cout<<"Right triangle"<<"\n";
else
cout<<"Obtuse triangle" <<"\n";
if(s[0]==s[1]||s[0]==s[2]||s[1]==s[2])
cout<<"Isosceles triangle"<<"\n";
if(s[0]==s[1]&&s[1]==s[2])
cout<<"Equilateral triangle"<<"\n";
}
P4414
[COCI2006-2007#2] ABC
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
#define ios ios::sync_with_stdio(false);cin.tie(0), cout.tie(0)
const int N = 1e6;
int main()
{
int s[5];
for(int i = 0;i<3;i++)
cin>>s[i];
sort(s,s+3);
char ch[5];
cin>>ch;
for(int i = 0;i<3;i++)
cout<
想要加入挑战或代码交流,请私信作者(看到必回复!!!)
作者本人是一名大一小白(:
滑稽保命(: