• hdu rightmost


    Rightmost Digit

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
    Total Submission(s): 4312    Accepted Submission(s): 1123
     
    Problem Description
    Given a positive integer N, you should output the most right digit of N^N.
     
    Input
    The input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. Each test case contains a single positive integer N(1<=N<=1,000,000,000).
     
    Output
    For each test case, you should output the rightmost digit of N^N.
     
    Sample Input
    2
    3
    4
     
    Sample Output
    7
    6
    Hint
    In the first case, 3 * 3 * 3 = 27, so the rightmost digit is 7. In the second case, 4 * 4 * 4 * 4 = 256, so the rightmost digit is 6.
     
    Author
    Ignatius.L
     
     
    #include<cstdio>
                        
    int main(){
    	long N;
    	int n,m;
    	while(scanf("%d",&n)==1){
    		for(int i=0;i<n;i++)
    		{	
    			int ans=1;
    			scanf("%d",&N);
    			m=N%4;
    			for(int j=0;j<m+4;j++)
    			{
    				ans=ans*(N%10);
    				if(ans>9)
    					ans=ans%10;
    			}
    		
    			printf("%d\n",ans);
    		}
    		
    	}
    return 0;}
    

      

  • 相关阅读:
    JS
    Python之缩进块
    Python快捷键
    Python介绍
    SOAP UI-----测webservice接口
    jmeter分布式压测(多台电脑一起压测)
    jmeter操作数据库
    jmeter压测
    jmeter关联
    jmeter参数化
  • 原文地址:https://www.cnblogs.com/wxhzt/p/3017875.html
Copyright © 2020-2023  润新知