8 条题解

  • 2
    @ 2023-1-26 16:10:56
    #include<bits/stdc++.h>
    using namespace std;
    int zsj[100000000],ans; 
    bool zs(int x)//判断质数,大家应该都会 
    {
    	for(int i=2;i*i<=x;i++)
    	{
    		if(!(x%i))return false;
    	}
    	return true;
    }
    void print(int x)//输出函数 
    {
    	for(int i=3;i<=x/2;i++)
    	{
    		if(zsj[i]!=0||zs(i))//i是质数 
    		{
    			if(zsj[x-i]!=0||zs(x-i))//x-i也是质数 
    			{
    				cout<<i<<"+"<<x-i<<"="<<x<<"\n";
    				ans++;//计数 
    			}
    		}
    	}
    }
    int main()
    {
    	int m,n;
    	cin>>m>>n;
    	for(int i=m;i<=n;i+=2)
    	{
    		print(i);//输出i的所有分解情况 
    	}
    	cout<<ans;
    	return 0;
    }
    
  • 1
    @ 2023-5-27 13:39:17

    #include <iostream> #include <cmath> #include <iomanip> #include <stack> #include <algorithm> #include <string> #include <cstring> #include <cstdio> using namespace std; const int INF = 0x3f3f3f3f; int main() { int l , r , sum = 0; cin >> l >> r; if(l % 2 == 1) l++; for(int i = l;i <= r;i += 2) { for(int j = 3;j <= i;j += 2) { int t = i - j; if(t < j) { break; } int flag = 1; for(int k = 3;flag == 1 && k * k <= j;k++) { if(j % k == 0) flag = 0; } for(int k = 3;flag == 1 && k*k <= t;k++) { if(t % k == 0) flag = 0; } if(flag == 0) { continue; } else { cout << j << "+" << t << "=" << i << endl; sum++; }

    }
    }
    cout << sum << endl;
    return 0;
    

    }

    • 0
      @ 2024-6-17 20:25:52
      #include<bits/stdc++.h>
      using namespace std;
      int n,m,cnt=0;
      int check(int n){
      	if(n<2) return 0;
      	for(int i=2;i<n;i++){
      		if(n%i==0){
      			return 0;
      		}
      	}
      	return 1;
      }
      void print(int x){
      	for(int i=2;i<=x/2;i++){
      		if(check (i)){
      				if(check (x-i)){
      					cout<<i<<"+"<<x-i<<"="<<i+x-i<<endl;
      					cnt++;
      				}
      		}
      	}
      }
      int main(){
      
      	cin>>n>>m;
      	for(int i=n;i<=m;i++){
      		if(i%2==0){
      			print(i);
      		}
      	}
      	cout<<cnt;
      }
      
      • 0
        @ 2024-4-2 23:56:28
        #include <bits/stdc++.h>
        using namespace std;
        int a[3432],b,c,zssl,sum = 0;
        void zs(int c){
        	bool l;
        	for(int i = 1,j = 3 ; j <= c ; j++){
        		if(j % 2 == 0) continue;
        		l = true;
        		for(int k = sqrt(j) ; k < j / 2; k++){
        			if(j % k == 0 && k != 1){
        				l = false;
        				break;
        			}
        		}
        		if(l){
        			a[i] = j;
        			zssl = i;
        			i++;
        		}
        	}
        }
        int main(){
        	cin >> b >> c;
        	zs(c);
        	for(int i = b ; i <= c ; i++){
        		if(i % 2 == 1) continue;
        		for(int j = 1 ; j <= zssl ; j++){
        			for(int k = 1 ; k <= zssl ; k++){
        				if(a[j] + a[k] == i && a[j] <= a[k]){
        					cout << a[j] << "+" << a[k] << "=" << i << endl;
        					sum++;
        				}
        			}
        		}
        	}
        	cout << sum << endl;
        	return 0;
        }
        
        • 0
          @ 2023-5-26 20:46:56
          #include <queue>
          #include <math.h>
          #include <stack>
          #include <stdio.h>
          #include <iostream>
          #include <vector>
          #include <iomanip>
          #include <string.h>
          #include <algorithm>
          #include <cstring>
          #include <bits/stdc++.h>
          using namespace std;
          int a; 
          bool zhi(int x){
          	for(int i=2;i*i<=x;i++){
          		if(!(x%i))return false;
          	}
          	return true;
          }
          void shu(int x){
          	for(int i=3;i<=x/2;i++)	{
          		if(zhi(i)==1){
          			if(zhi(x-i)==1){
          				cout<<i<<"+"<<x-i<<"="<<x<<"\n";
          				a++; 
          			}
          		}
          	}
          }
          int main(){
          	int m,n;
          	cin>>m>>n;
          	for(int i=m;i<=n;i+=2){
          		shu(i); 
          	}
          	cout<<a;
          	return 0;
          }
          
          • 0
            @ 2023-5-21 18:47:51
            #include<bits/stdc++.h>
            using namespace std;
            int l[10000000] , ans; 
            bool f(int x)
            {
            	for(int i = 2;i * i <= x;i++)
            	{
            		if(!(x % i))
            			return false;
            	}
            	return true;
            }
            void print(int x)
            {
            	for(int i = 3;i <= x / 2;i++)
            	{
            		if(l[i] != 0 || f(i))
            		{
            			if(l[x - i] != 0 || f(x - i)) 
            			{
            				cout << i << "+" << x - i << "=" << x << "\n";
            				ans++;
            			}
            		}
            	}
            }
            int main()
            {
            	int a , b;
            	cin>> a >> b;
            	for(int i = a;i <= b;i += 2)
            	{
            		print(i);
            	}
            	cout << ans;
            	return 0;
            }
            
            • 0
              @ 2022-3-9 19:21:09
              #include <stdio.h>
              #include <iostream>
              using namespace std;
              int main()
              {
              	int l , r,sum=0;
              	cin >> l >> r;
              	if(l%2 == 1)
              		l++;
              
              	for(int i = l ; i <= r ; i+=2) 
              	{
              		for(int j = 3 ; j <= i ; j+= 2) // 2
              		{
              			int t = i - j;
              			if(t < j)
              			{
              				break;
              			}
              			int flag = 1;
              			for(int k = 3 ; flag == 1 && k*k <= j ; k++ ) // 判断j是否质数  
              			{
              				if(j%k == 0)
              					flag = 0;
              			}
              			for(int k = 3 ; flag == 1 && k*k <= t ; k++) // 判断t是不是质数
              			{
              				if(t % k == 0)
              					flag = 0;
              			}
              			if(flag == 0)
              				continue;
              			else 
              			{
              				cout << j << "+"<<t << "="<<i<<endl;
              				sum++;
              			}
              
              		}
              	}
              	cout << sum << endl;
              }
              
              • -2
                @ 2022-2-12 10:14:31

                #include <iostream> #include <stdio.h> using namespace std; int main() { int l , r , sum = 0; cin >> l >> r; if (l % 2 == 1) { l+= 1; } for (int i = l; i <= r ; i += 2) { for (int j = 3; j <= i ; j += 2 ) { int p = i - j ; int flag = 1; if (p < j ) { break; } for (int k = 3; k * k <= j && flag ; k ++) { if (j % k ==0 ) { flag = 0; } } for ( int k = 3 ; k * k <= p && flag ; k ++) { if (p % k == 0) { flag = 0; } } if (flag == 0) { continue; } cout << j << "+" << p << "=" << i <<endl; sum ++; } } cout << sum << endl; }

                • 1

                信息

                ID
                908
                时间
                1000ms
                内存
                128MiB
                难度
                5
                标签
                递交数
                499
                已通过
                198
                上传者