fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. // Function to decode the number to the name "Utsav Krishna"
  8. string decodeNumberToName(long long input) {
  9. // Transformation logic hidden in a mathematical pattern
  10. long long transformedInput = input;
  11.  
  12. // Apply some transformation (just for complexity)
  13. transformedInput = (transformedInput / 1000000) * 3 + (transformedInput % 100000);
  14. transformedInput = transformedInput % 1000000;
  15.  
  16. // Now check the transformed input
  17. if (transformedInput == 238335) {
  18. return "Utsav Krishna"; // If the transformed value matches, return the name
  19. } else {
  20. return "Incorrect input!";
  21. }
  22. }
  23.  
  24. int main() {
  25. long long input;
  26.  
  27. // Ask for input
  28. cout << "Enter the number (10 digits): ";
  29. cin >> input;
  30.  
  31. // Call the function to decode the input
  32. string result = decodeNumberToName(input);
  33.  
  34. // Output the result
  35. cout << "Output: " << result << endl;
  36.  
  37. return 0;
  38. }
  39.  
Success #stdin #stdout 0.01s 5284KB
stdin
/*  Berechnung des Hamming-Abstandes zwischen zwei 128-Bit Werten in 	*/
/*	einer Textdatei. 													*/
/*  Die Werte müssen auf einer separaten Zeile gespeichert sein			*/
/* 																		*/
/*	Erstellt: 17.5.2010													*/
/*  Autor: Thomas Scheffler												*/

#include <stdio.h>
#include <stdlib.h>

#define ARRAY_SIZE 32

unsigned Hamdist(unsigned x, unsigned y)
{
  unsigned dist = 0, val = x ^ y;
 
  // Count the number of set bits
  while(val)
  {
    ++dist; 
    val &= val - 1;
  }
 
  return dist;
}



int main (void)
{
	char hex;
	int i;
	int a[ARRAY_SIZE];
	int b[ARRAY_SIZE];
	int hamDist = 0;
	FILE* fp;
	
	//Arrays mit 0 initialisieren
	for (i = 0; i < ARRAY_SIZE; ++i)
	{
  		a[i] = 0;
  		b[i] = 0;
	}

	
	fp = fopen("hex.txt","r");
	if (fp == NULL) 
	{
		printf("Die Datei hex.txt wurde nicht gefunden!");
		exit(EXIT_FAILURE);
	}

	i=0;
	printf("1.Zeile einlesen.\n");

 	while((hex=fgetc(fp))!='\n' && hex != EOF)
    {
        a[i]=strtol(&hex,0,16);
		i++;
    }
	i=0;
	printf("2.Zeile einlesen.\n");

 	while((hex=fgetc(fp))!='\n' && hex != EOF)
    {
    	b[i]=strtol(&hex,0,16);
        i++;
    }
	fclose(fp);

	printf("Hamming-Abweichung pro Nibble:\n");
	for (i = 0; i < ARRAY_SIZE; ++i)
	{
		printf ("%i\t%i\t%i\n",a[i],b[i],Hamdist(a[i],b[i]));
		hamDist += Hamdist(a[i],b[i]);
	}
	printf ("\nHamming-Abweichung der Hash-Werte:%d\n",hamDist);
}

stdout
Enter the number (10 digits): Output: Incorrect input!