3 条题解

  • 1
    @ 2023-11-19 10:46:11
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
    	int n,gs=0;
    	cin>>n;
    	for(int i=1;i<n;i++){
    		if(i%3==2&&i%5==3&&i%7==2)
    		gs++; 
    	}cout<<gs;
    	return 0;
    }
    
    
    • 1
      @ 2023-11-18 14:38:21

      #include<bits/stdc++.h> using namespace std; int main(){ int n,sum=0,i; cin>>n; for(i=1;i<=n;i++){ if(i%32&&i%53&&i%7==2) sum=sum+1; } cout<<sum; return 0; }

      • 0
        @ 2023-11-30 19:13:28

        打表+二分 时间O(log n)

        #include<bits/stdc++.h>
        using namespace std;
        char ch;
        inline int read(){
        	int ans=0;
        	ch=getchar();
        	while(ch<'0'||ch>'9')ch=getchar();
        	while(ch>='0'&&ch<='9')
        		ans=(ans<<1)+(ans<<3)+(ch^'0'),ch=getchar();
        	return ans;
        }
        int a[]={0,23,128,233,338,443,548,653,758,863,968,1073,1178,1283,1388,1493,1598,1703,1808,1913};
        int main(){
        	int n=read(),l=0,r=19;
        	while(l<r){
        		int mid=r-(r-l>>1);
        		if(n>=a[mid])l=mid;
        		else r=mid-1;
        	}
        	cout<<l;
        	return 0;
        }
        
        • 1

        信息

        ID
        56
        时间
        1000ms
        内存
        16MiB
        难度
        3
        标签
        递交数
        75
        已通过
        43
        上传者