using namespace std;
//平+立
int sq(int temp){
for(int j=0;j*j<=temp;j++){
if(j*j==temp)
return j;
}
return 0;
}
int main(){
int t;
while(cin>>t){
int n,count=0;
for(int i=1;i*i*i<=t;i++){
if(sq(i*i*i))
count++;
}
cout<<count<<endl;
}
return 0;
}
A
#include<iostream>
#include<string.h>
#include<string>
using namespace std;
int judgea(int x){
for(int i=1;i<=x;i++) {
if(i*i*i==x) return 1;
}
return 0;
}
int judgeb(int x){
for(int i=1;i<=x;i++) {
if(i*i==x) return 1;
}
return 0;
}
int main(){
int t;cin>>t;int a ,b;
while(t--){
int x;cin>>x;int count=0;
for(int i=0;i<=x;i++){
a=judgea(i);
b=judgeb(i);
if(a==1&&b==1){
count++;
}
}
cout<<count<<endl;
}
return 0;
}
c
#include<iostream> #include<string.h> using namespace std; struct node{ char data; node *lchild,*rchild; }; node tree[105]; int loc; node *create(){ tree[loc].lchild=tree[loc].rchild=NULL; return &tree[loc++]; } void Pre(node *t){ if(t){ Pre(t->lchild); Pre(t->rchild); cout<<t->data; } } string str1,str2; node *build(int s1,int e1,int s2,int e2){ node *ret=create(); ret->data=str1[s1]; int rootIdx; for(int i=s2;i<=e2;i++){ if(str2[i]==str1[s1]){ rootIdx=i; break; } } if(rootIdx!=s2){ ret->lchild=build(s1+1,s1+(rootIdx-s2),s2,rootIdx-1); } if(rootIdx!=e2){ ret->rchild=build(s1+(rootIdx-s2)+1,e1,rootIdx+1,e2); } return ret; } int main(){ while(cin>>str1){ cin>>str2; loc=0; int l1=str1.length(); int l2=str2.length(); node *t=build(0,l1-1,0,l2-1); Pre(t); cout<<endl; } return 0; }
b
#include<iostream>
#include<string.h>
#include<cmath>
#include<algorithm>
using namespace std;
int a[100];
void nixu(int l,int r){
int len=r-l+1;//12345 14325 1 3
int b[len];
for(int i=0;i<len;i++){
b[i]=a[r-i];
}
for(int i=l;i<=r;i++){
a[i]=b[i-l];
}
}
void ti(int l,int r,int y){
for(int i=l;i<=r;i++){
a[i]=y;
}
}
int main(){
int m,n,x,y;
cin>>n>>m;
int l,r;
for(int i=0;i<n;i++){
cin>>a[i];
}
while(m--){
cin>>x;
if(x==1) {
cin>>l>>r;
nixu(l-1,r-1);
for(int i=0;i<n;i++){
cout<<a[i]<<" ";
}
}
else if(x==3){
cin>>l>>r; cin>>y;
ti(l-1,r-1,y);
for(int i=0;i<n;i++){
cout<<a[i]<<" ";
}
}
else if(x==4){
cin>>l>>r;
sort(a+l,a+r);
for(int i=0;i<n;i++){
cout<<a[i]<<" ";
}
}
}
return 0;
}